How to convert "DOMNodeInserted" to Mutation observers?
I am trying to convert DOMNodeInserted to Mutation observers, because I
heard that Mutation events is deprecated, but I can't.
This is the original code;
//works well
document.body.addEventListener('DOMNodeInserted', function (event)
{Container(event.target);}, false);
I wrote this in reference to this page;
Are DOM Mutation Observers slower than DOM Mutation Events? , but it
doesn't work;
// does not work(tested with chrome 28)
var observer = new MutationObserver(function (event) {
observer.disconnect();
Container(event.target);
});
observer.observe(document, {subtree: true, childList: true })
What is the problem? What should I do?
No comments:
Post a Comment