admin管理员组

文章数量:1392003

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: /

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?

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/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?

Share Improve this question edited Jun 1, 2014 at 17:28 Matt 75.3k26 gold badges156 silver badges180 bronze badges asked Nov 29, 2013 at 23:47 GetFreeGetFree 42.7k20 gold badges86 silver badges106 bronze badges 1
  • 1 It's now fixed. – cprcrack Commented May 17, 2017 at 13:44
Add a ment  | 

1 Answer 1

Reset to default 7

It is a bug in Chrome, reported here. The bug is still open, which means it has not been fixed.

本文标签: javascriptManually resizing an element doesn39t fire a mutation observer in ChromeStack Overflow