You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11 lines
5.6 KiB

4 months ago
/*!
* @antv/g-dom-mutation-observer-api
* @description A simple implementation of DOM MutationObserver API.
* @version 2.0.38
* @date 7/30/2025, 1:34:51 PM
* @author AntVis
* @docs https://g.antv.antgroup.com/
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.DOMMutationObserverAPI={}),e.window.G)}(this,function(e,t){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function n(e){var t=function(e,t){if("object"!=i(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==i(t)?t:t+""}function o(e,t){for(var r=0;t.length>r;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,n(i.key),i)}}function s(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var a,u,l=function(){function e(t,i){r(this,e),this.addedNodes=[],this.attributeName=null,this.attributeNamespace=null,this.nextSibling=null,this.oldValue=null,this.previousSibling=null,this.removedNodes=[],this.type=t,this.target=i}return s(e,null,[{key:"copy",value:function(t){var r=new e(t.type,t.target);return r.addedNodes=t.addedNodes.slice(),r.removedNodes=t.removedNodes.slice(),r.previousSibling=t.previousSibling,r.nextSibling=t.nextSibling,r.attributeName=t.attributeName,r.attributeNamespace=t.attributeNamespace,r.oldValue=t.oldValue,r}}])}(),v=0,c=new WeakMap,d=function(){return s(function e(t,i,n){r(this,e),this.transientObservedNodes=[],this.observer=t,this.target=i,this.options=n},[{key:"enqueue",value:function(e){var r=this.observer.records,i=r.length;if(r.length>0){var n=function(e,t){return e===t?e:u&&function(e){return e===u||e===a}(e)?u:null}(r[i-1],e);if(n)return void(r[i-1]=n)}else m.push(this.observer),b||(b=!0,void 0!==t.runtime.globalThis?t.runtime.globalThis.setTimeout(p):p());r[i]=e}},{key:"addListeners",value:function(){this.addListeners_(this.target)}},{key:"addListeners_",value:function(e){var r=this.options;r.attributes&&e.addEventListener(t.ElementEvent.ATTR_MODIFIED,this,!0),r.childList&&e.addEventListener(t.ElementEvent.INSERTED,this,!0),(r.childList||r.subtree)&&e.addEventListener(t.ElementEvent.REMOVED,this,!0)}},{key:"removeListeners",value:function(){this.removeListeners_(this.target)}},{key:"removeListeners_",value:function(e){var r=this.options;r.attributes&&e.removeEventListener(t.ElementEvent.ATTR_MODIFIED,this,!0),r.childList&&e.removeEventListener(t.ElementEvent.INSERTED,this,!0),(r.childList||r.subtree)&&e.removeEventListener(t.ElementEvent.REMOVED,this,!0)}},{key:"removeTransientObservers",value:function(){var e=this.transientObservedNodes;this.transientObservedNodes=[],e.forEach(function(e){this.removeListeners_(e);for(var t=c.get(e),r=0;t.length>r;r++)if(t[r]===this){t.splice(r,1);break}},this)}},{key:"handleEvent",value:function(e){var r,i;switch(e.stopImmediatePropagation(),e.type){case t.ElementEvent.ATTR_MODIFIED:var n=e.attrName,o=e.relatedNode.namespaceURI;(r=f("attributes",i=e.target)).attributeName=n,r.attributeNamespace=o;var s=e.attrChange===t.MutationEvent.ADDITION?null:e.prevValue;h(i,function(e){if(e.attributes&&(!e.attributeFilter||!e.attributeFilter.length||-1!==e.attributeFilter.indexOf(n)||-1!==e.attributeFilter.indexOf(o)))return e.attributeOldValue?function(e){return u||((u=l.copy(a)).oldValue=e,u)}(s):r});break;case t.ElementEvent.REMOVED:case t.ElementEvent.INSERTED:var v,c,d=e.target;e.type===t.ElementEvent.INSERTED?(v=[d],c=[]):(v=[],c=[d]);var b=d.previousSibling,m=d.nextSibling;(r=f("childList",i=e.relatedNode)).addedNodes=v,r.removedNodes=c,r.previousSibling=b,r.nextSibling=m,h(i,function(e){if(e.childList)return r})}a=u=void 0}}])}();functi
//# sourceMappingURL=index.umd.min.js.map