'Why is the DOMSubtreeModified event deprecated in DOM level 3?
Why is the DOMSubtreeModified event deprecated and what are we supposed to use instead?
Solution 1:[1]
I think the replacement will be mutation observers: https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
var whatToObserve = {childList: true, attributes: true, subtree: true, attributeOldValue: true, attributeFilter: ['class', 'style']};
var mutationObserver = new MutationObserver(function(mutationRecords) {
$.each(mutationRecords, function(index, mutationRecord) {
if (mutationRecord.type === 'childList') {
if (mutationRecord.addedNodes.length > 0) {
//DOM node added, do something
}
else if (mutationRecord.removedNodes.length > 0) {
//DOM node removed, do something
}
}
else if (mutationRecord.type === 'attributes') {
if (mutationRecord.attributeName === 'class') {
//class changed, do something
}
}
});
});
mutationObserver.observe(document.body, whatToObserve);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ralfthewise |
