手动调整元素大小不会触发Chrome中的变异观察者

时间:2013-11-29 23:47:06

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

我有DIV样式resize: both,然后我设置了一个MutationObserver来监听属性的变化。

mutObs = new MutationObserver(function () {
    console.log('Hello');
});

elem = document.getElementById('aDiv');
mutObs.observe(elem, {
    attributes: true
});

elem.style.width = '300px'; //this fires the observer callback as expected

我做了一个小提琴:http://jsfiddle.net/2NQQu/2/

在Chrome(我测试Chrome 31)中,当您使用鼠标调整DIV大小时,不会触发回调。在Firefox中它可以正常工作。

这种行为是故意的和/或标准的吗?这是一个错误吗?

1 个答案:

答案 0 :(得分:7)

这是Chrome中的一个错误,reported here。该错误仍然是开放的,这意味着它尚未修复。