Mutation observers --- subtree

I am reading this http://lists.w3.org/Archives/Public/public-webapps/2011JulSep/1622.html and it looks like the behavior of Chrome is different from the specification. If I understand the specifications correctly, the definition of a "subtree" for an element means that changes in the subtree of this element (including the element itself) should be reported. However, when I execute this part of the code, I get nothing.

var observer = new WebKitMutationObserver(function(e){console.log(e);}) observer.observe(document.body, {subtree:true, attributes:true}); document.body.appendChild(document.createElement('div')); 

What am I missing? Can anyone elaborate on this? Thanks!

+6
source share
1 answer

The documentation is unclear, but the subtree is ignored unless you also specify childList: true.
The case for attributes and attribute Filter is the same
hope he still helps

+8
source

Source: https://habr.com/ru/post/915546/


All Articles