变异观察者-子树

人气:693 发布:2022-10-16 标签: webkit chromium mutation-observers

问题描述

我正在阅读http://lists.w3.org/Archives/Public/public-webapps/2011JulSep/1622.html,似乎Chrome的行为与规范相反。如果我正确理解了规范,为元素定义"子树"意味着应该报告对该元素的子树(包括元素本身)的更改。但是,在执行这段代码时,我什么也得不到。

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

我错过了什么?有没有人能详细说明一下? 谢谢!

推荐答案

文档不清楚,但subtree将被忽略,除非您还指定了childList:true

attributesattributeFilter的大小写相同。

希望它仍然有帮助。

308