Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
599 views
in Technique[技术] by (71.8m points)

javascript - 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.

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...