From aaa50d6b7be0aa3ad14d21fbe46ec0525c519f33 Mon Sep 17 00:00:00 2001 From: tophf Date: Sat, 15 Apr 2017 13:25:48 +0300 Subject: [PATCH] fixup for Chrome 49 without Symbol.iterator --- apply.js | 7 ++++--- install.js | 11 +++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/apply.js b/apply.js index 6dd2c67d..143bba3f 100644 --- a/apply.js +++ b/apply.js @@ -261,9 +261,10 @@ function initDocRewriteObserver() { }; // detect documentElement being rewritten from inside the script docRewriteObserver = new MutationObserver(mutations => { - for (const mutation of mutations) { - for (const node of mutation.addedNodes) { - if (node.localName == 'html') { + for (let m = mutations.length; --m >= 0;) { + const added = mutations[m].addedNodes; + for (let n = added.length; --n >= 0;) { + if (added[n].localName == 'html') { reinjectStyles(); return; } diff --git a/install.js b/install.js index d374a810..0b9e7c91 100644 --- a/install.js +++ b/install.js @@ -143,14 +143,17 @@ function getResource(url) { function rebrand(mutations) { /* stylish to stylus; https://github.com/schomery/stylish-chrome/issues/12 */ - for (const mutation of mutations) { - for (const addedNode of mutation.addedNodes) { + for (let m = mutations.length; --m >= 0;) { + const added = mutations[m].addedNodes; + for (let n = added.length; --n >= 0;) { + const addedNode = added[n]; if (addedNode.nodeType != Node.ELEMENT_NODE) { continue; } const elementsToCheck = addedNode.matches('.install-status') ? [addedNode] - : Array.prototype.slice.call(addedNode.getElementsByClassName('install-status')); - for (const el of elementsToCheck) { + : addedNode.getElementsByClassName('install-status'); + for (let i = elementsToCheck.length; --i >= 0;) { + const el = elementsToCheck[i]; if (!el.textContent.includes('Stylish')) { continue; }