如何检查MutationObserver是否在监视某些DOM节点?

时间:2018-09-13 05:52:50

标签: javascript dom

const selectorClassNameDesktopGlobalHeaderItemsRight = `.target-class-name`;
const desktopGlobalHeaderItemsRightElm = document.querySelector(selectorClassNameDesktopGlobalHeaderItemsRight);
const desktopGlobalHeaderItemsRightElmObserver = new MutationObserver(desktopGlobalHeaderItemsRightElmObserverCallback);
desktopGlobalHeaderItemsRightElmObserver.observe(desktopGlobalHeaderItemsRightElm, desktopGlobalHeaderItemsRightElmObserverConfig);

有没有办法我可以知道MutationObsever仍在跟踪DOM元素,在这种情况下为desktopGlobalHeaderItemsRightElm

我问是因为在被监视的DOM节点中进行了重新构造,甚至在检查后引用也相同,节点更改不再触发回调函数。

0 个答案:

没有答案