简体   繁体   English

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

[英]Manually resizing an element doesn't fire a mutation observer in Chrome

I have a DIV with style resize: both and then I set a MutationObserver that listens for changes in attributes. 我有一个样式resize: bothDIV 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

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

In Chrome (I tested Chrome 31) the callback is not fired when you resize the DIV with the mouse. 在Chrome(我测试过Chrome 31)中,当您使用鼠标调整DIV大小时,不会触发回调。 In Firefox it works fine. 在Firefox中它工作正常。

Is this behavior intentional and/or standard? 这种行为是故意的和/或标准的吗? Is it a bug? 这是一个错误吗?

It is a bug in Chrome, reported here . 报道 ,这是Chrome中的一个错误。 The bug is still open, which means it has not been fixed. 该错误仍然是开放的,这意味着它尚未修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM