Skip to content

Commit 09d4cf1

Browse files
alubbemarcj
authored andcommitted
Make the MutationObserver of ResizeSensor compatible with new Chrome version (#249)
The for-in loop over the `NodeList` now goes through the prototype chain, so we check `hasOwnProperty` first
1 parent 9cb667d commit 09d4cf1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/ResizeSensor.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,14 @@
278278
if (typeof MutationObserver !== "undefined") {
279279
var observer = new MutationObserver(function (mutations) {
280280
for (var i in mutations) {
281-
var items = mutations[i].addedNodes;
282-
for (var j = 0; j < items.length; j++) {
283-
if (items[j].resizeSensor) {
284-
ResizeSensor.reset(items[j]);
281+
if (mutations.hasOwnProperty(i)) {
282+
var items = mutations[i].addedNodes;
283+
for (var j = 0; j < items.length; j++) {
284+
if (items[j].resizeSensor) {
285+
ResizeSensor.reset(items[j]);
286+
}
285287
}
286288
}
287-
288289
}
289290
});
290291

0 commit comments

Comments
 (0)