【问题标题】:Mutation Obervers in Chrome are not detecting attribute and css changesChrome 中的 Mutation Observers 未检测到属性和 css 更改
【发布时间】:2012-06-16 16:54:33
【问题描述】:

我在 Chrome 19 中,我创建了一个新的变异观察者对象:

var observer = new WebKitMutationObserver(function(mutations, observer) {
  console.log(mutations, observer);
});

然后我观察:

observer.observe(document, {
  subtree: true,
  childList: true,
  characterData: true,
  attribute: true      
});

似乎只有在我插入或删除节点或更改节点的文本时才会触发此设置。如果我更改元素的属性或内联 css 样式,它不会被触发。这是为什么呢?

【问题讨论】:

    标签: javascript html dom google-chrome mutation-observers


    【解决方案1】:

    根据the spec draft,你要设置的属性是attributes: true,而不是attribute: true

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-06
      • 1970-01-01
      • 2011-11-09
      • 2017-05-04
      相关资源
      最近更新 更多