Skip to content

Commit

Permalink
Make the MutationObserver of ResizeSensor compatible with new Chrome …
Browse files Browse the repository at this point in the history
…version (#249)

The for-in loop over the `NodeList` now goes through the prototype chain, so we check `hasOwnProperty` first
  • Loading branch information
alubbe authored and marcj committed Nov 9, 2018
1 parent 9cb667d commit 09d4cf1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/ResizeSensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,14 @@
if (typeof MutationObserver !== "undefined") {
var observer = new MutationObserver(function (mutations) {
for (var i in mutations) {
var items = mutations[i].addedNodes;
for (var j = 0; j < items.length; j++) {
if (items[j].resizeSensor) {
ResizeSensor.reset(items[j]);
if (mutations.hasOwnProperty(i)) {
var items = mutations[i].addedNodes;
for (var j = 0; j < items.length; j++) {
if (items[j].resizeSensor) {
ResizeSensor.reset(items[j]);
}
}
}

}
});

Expand Down

0 comments on commit 09d4cf1

Please sign in to comment.