Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: runtime/bin/vmservice/observatory/deployed/web/packages/mutation_observer/mutation_observer.min.js

Issue 839543002: Revert "Build Observatory with runtime" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 if(!window.MutationObserver&&!window.WebKitMutationObserver){!function(global){v ar SideTable;if(typeof WeakMap!=="undefined"&&navigator.userAgent.indexOf("Firef ox/")<0){SideTable=WeakMap}else{!function(){var defineProperty=Object.defineProp erty;var hasOwnProperty=Object.hasOwnProperty;var counter=(new Date).getTime()%1 e9;SideTable=function(){this.name="__st"+(Math.random()*1e9>>>0)+(counter++ +"__ ")};SideTable.prototype={set:function(key,value){defineProperty(key,this.name,{v alue:value,writable:true})},get:function(key){return hasOwnProperty.call(key,thi s.name)?key[this.name]:undefined},"delete":function(key){this.set(key,undefined) }}}()}var registrationsTable=new SideTable;var setImmediate=window.msSetImmediat e;if(!setImmediate){var setImmediateQueue=[];var sentinel=String(Math.random()); window.addEventListener("message",function(e){if(e.data===sentinel){var queue=se tImmediateQueue;setImmediateQueue=[];queue.forEach(function(func){func()})}});se tImmediate=function(func){setImmediateQueue.push(func);window.postMessage(sentin el,"*")}}var isScheduled=false;var scheduledObservers=[];function scheduleCallba ck(observer){scheduledObservers.push(observer);if(!isScheduled){isScheduled=true ;setImmediate(dispatchCallbacks)}}function wrapIfNeeded(node){return window.Shad owDOMPolyfill&&window.ShadowDOMPolyfill.wrapIfNeeded(node)||node}function dispat chCallbacks(){isScheduled=false;var observers=scheduledObservers;scheduledObserv ers=[];observers.sort(function(o1,o2){return o1.uid_-o2.uid_});var anyNonEmpty=f alse;observers.forEach(function(observer){var queue=observer.takeRecords();remov eTransientObserversFor(observer);if(queue.length){observer.callback_(queue,obser ver);anyNonEmpty=true}});if(anyNonEmpty)dispatchCallbacks()}function removeTrans ientObserversFor(observer){observer.nodes_.forEach(function(node){var registrati ons=registrationsTable.get(node);if(!registrations)return;registrations.forEach( function(registration){if(registration.observer===observer)registration.removeTr ansientObservers()})})}function forEachAncestorAndObserverEnqueueRecord(target,c allback){for(var node=target;node;node=node.parentNode){var registrations=regist rationsTable.get(node);if(registrations){for(var j=0;j<registrations.length;j++) {var registration=registrations[j];var options=registration.options;if(node!==ta rget&&!options.subtree)continue;var record=callback(options);if(record)registrat ion.enqueue(record)}}}}var uidCounter=0;function MutationObserver(callback){this .callback_=callback;this.nodes_=[];this.records_=[];this.uid_=++uidCounter}Mutat ionObserver.prototype={observe:function(target,options){target=wrapIfNeeded(targ et);if(!options.childList&&!options.attributes&&!options.characterData||options. attributeOldValue&&!options.attributes||options.attributeFilter&&options.attribu teFilter.length&&!options.attributes||options.characterDataOldValue&&!options.ch aracterData){throw new SyntaxError}var registrations=registrationsTable.get(targ et);if(!registrations)registrationsTable.set(target,registrations=[]);var regist ration;for(var i=0;i<registrations.length;i++){if(registrations[i].observer===th is){registration=registrations[i];registration.removeListeners();registration.op tions=options;break}}if(!registration){registration=new Registration(this,target ,options);registrations.push(registration);this.nodes_.push(target)}registration .addListeners()},disconnect:function(){this.nodes_.forEach(function(node){var re gistrations=registrationsTable.get(node);for(var i=0;i<registrations.length;i++) {var registration=registrations[i];if(registration.observer===this){registration .removeListeners();registrations.splice(i,1);break}}},this);this.records_=[]},ta keRecords:function(){var copyOfRecords=this.records_;this.records_=[];return cop yOfRecords}};function MutationRecord(type,target){this.type=type;this.target=tar get;this.addedNodes=[];this.removedNodes=[];this.previousSibling=null;this.nextS ibling=null;this.attributeName=null;this.attributeNamespace=null;this.oldValue=n ull}MutationObserver.prototype.constructor=MutationObserver;MutationObserver.nam e="MutationObserver";MutationRecord.prototype.constructor=MutationRecord;Mutatio nRecord.name="MutationRecord";function copyMutationRecord(original){var record=n ew MutationRecord(original.type,original.target);record.addedNodes=original.adde dNodes.slice();record.removedNodes=original.removedNodes.slice();record.previous Sibling=original.previousSibling;record.nextSibling=original.nextSibling;record. attributeName=original.attributeName;record.attributeNamespace=original.attribut eNamespace;record.oldValue=original.oldValue;return record}var currentRecord,rec ordWithOldValue;function getRecord(type,target){return currentRecord=new Mutatio nRecord(type,target)}function getRecordWithOldValue(oldValue){if(recordWithOldVa lue)return recordWithOldValue;recordWithOldValue=copyMutationRecord(currentRecor d);recordWithOldValue.oldValue=oldValue;return recordWithOldValue}function clear Records(){currentRecord=recordWithOldValue=undefined}function recordRepresentsCu rrentMutation(record){return record===recordWithOldValue||record===currentRecord }function selectRecord(lastRecord,newRecord){if(lastRecord===newRecord)return la stRecord;if(recordWithOldValue&&recordRepresentsCurrentMutation(lastRecord))retu rn recordWithOldValue;return null}function Registration(observer,target,options) {this.observer=observer;this.target=target;this.options=options;this.transientOb servedNodes=[]}Registration.prototype={enqueue:function(record){var records=this .observer.records_;var length=records.length;if(records.length>0){var lastRecord =records[length-1];var recordToReplaceLast=selectRecord(lastRecord,record);if(re cordToReplaceLast){records[length-1]=recordToReplaceLast;return}}else{scheduleCa llback(this.observer)}records[length]=record},addListeners:function(){this.addLi steners_(this.target)},addListeners_:function(node){var options=this.options;if( options.attributes)node.addEventListener("DOMAttrModified",this,true);if(options .characterData)node.addEventListener("DOMCharacterDataModified",this,true);if(op tions.childList)node.addEventListener("DOMNodeInserted",this,true);if(options.ch ildList||options.subtree)node.addEventListener("DOMNodeRemoved",this,true)},remo veListeners:function(){this.removeListeners_(this.target)},removeListeners_:func tion(node){var options=this.options;if(options.attributes)node.removeEventListen er("DOMAttrModified",this,true);if(options.characterData)node.removeEventListene r("DOMCharacterDataModified",this,true);if(options.childList)node.removeEventLis tener("DOMNodeInserted",this,true);if(options.childList||options.subtree)node.re moveEventListener("DOMNodeRemoved",this,true)},addTransientObserver:function(nod e){if(node===this.target)return;this.addListeners_(node);this.transientObservedN odes.push(node);var registrations=registrationsTable.get(node);if(!registrations )registrationsTable.set(node,registrations=[]);registrations.push(this)},removeT ransientObservers:function(){var transientObservedNodes=this.transientObservedNo des;this.transientObservedNodes=[];transientObservedNodes.forEach(function(node) {this.removeListeners_(node);var registrations=registrationsTable.get(node);for( var i=0;i<registrations.length;i++){if(registrations[i]===this){registrations.sp lice(i,1);break}}},this)},handleEvent:function(e){e.stopImmediatePropagation();s witch(e.type){case"DOMAttrModified":var name=e.attrName;var namespace=e.relatedN ode.namespaceURI;var target=e.target;var record=new getRecord("attributes",targe t);record.attributeName=name;record.attributeNamespace=namespace;var oldValue=e. attrChange===MutationEvent.ADDITION?null:e.prevValue;forEachAncestorAndObserverE nqueueRecord(target,function(options){if(!options.attributes)return;if(options.a ttributeFilter&&options.attributeFilter.length&&options.attributeFilter.indexOf( name)===-1&&options.attributeFilter.indexOf(namespace)===-1){return}if(options.a ttributeOldValue)return getRecordWithOldValue(oldValue);return record});break;ca se"DOMCharacterDataModified":var target=e.target;var record=getRecord("character Data",target);var oldValue=e.prevValue;forEachAncestorAndObserverEnqueueRecord(t arget,function(options){if(!options.characterData)return;if(options.characterDat aOldValue)return getRecordWithOldValue(oldValue);return record});break;case"DOMN odeRemoved":this.addTransientObserver(e.target);case"DOMNodeInserted":var target =e.relatedNode;var changedNode=e.target;var addedNodes,removedNodes;if(e.type=== "DOMNodeInserted"){addedNodes=[changedNode];removedNodes=[]}else{addedNodes=[];r emovedNodes=[changedNode]}var previousSibling=changedNode.previousSibling;var ne xtSibling=changedNode.nextSibling;var record=getRecord("childList",target);recor d.addedNodes=addedNodes;record.removedNodes=removedNodes;record.previousSibling= previousSibling;record.nextSibling=nextSibling;forEachAncestorAndObserverEnqueue Record(target,function(options){if(!options.childList)return;return record})}cle arRecords()}};global.MutationObserver=MutationObserver}(window)}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698