手动调整元素大小并不会触发Chrome中的突变观察者 [英] Manually resizing an element doesn't fire a mutation observer in Chrome
本文介绍了手动调整元素大小并不会触发Chrome中的突变观察者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 DIV
,样式为 resize:都是
,然后我设置了一个 MutationObserver
mutObs = new MutationObserver(function(){
console.log('Hello');
});
elem = document.getElementById('aDiv');
mutObs.observe(elem,{
attributes:true
});
elem.style.width ='300px'; / /这会触发观察者回调按预期
我做了一个小提琴: http://jsfiddle.net/2NQQu/2/
在Chrome (我测试过Chrome 31),当用鼠标调整 DIV
大小时,回调不会被触发。在Firefox中它工作正常。
这种行为是故意的还是标准的?它是一个错误吗? 解决方案
这是Chrome中的一个错误,在这里报告。该错误仍然是开放的,这意味着它还没有被修复。
I have a DIV
with style resize: both
and then I set a MutationObserver
that listens for changes in attributes.
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/
In Chrome (I tested Chrome 31) the callback is not fired when you resize the DIV
with the mouse. In Firefox it works fine.
Is this behavior intentional and/or standard? Is it a bug?
解决方案
It is a bug in Chrome, reported here. The bug is still open, which means it has not been fixed.
这篇关于手动调整元素大小并不会触发Chrome中的突变观察者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文