From d151dd0303c7d73e184122f237a53cd8ed4db721 Mon Sep 17 00:00:00 2001 From: Jason Date: Wed, 4 Mar 2015 14:03:29 -0600 Subject: [PATCH] Fix iframe mutation observer #3 --- apply.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apply.js b/apply.js index 53899df2..31c6a77c 100644 --- a/apply.js +++ b/apply.js @@ -97,7 +97,7 @@ function replaceAll(newStyles, doc) { // Observe dynamic IFRAMEs being added var iframeObserver = new MutationObserver(function(mutations) { - var styles = document.querySelectorAll('STYLE.stylish'); + var styles = Array.prototype.slice.call(document.querySelectorAll('STYLE.stylish')); if (styles.length == 0) { return; } @@ -105,9 +105,9 @@ var iframeObserver = new MutationObserver(function(mutations) { return "childList" === mutation.type; }).forEach(function(mutation) { Array.prototype.filter.call(mutation.addedNodes, function(node) { return "IFRAME" === node.tagName; }).filter(iframeIsDynamic).forEach(function(iframe) { - var doc = f.contentDocument; + var doc = iframe.contentDocument; styles.forEach(function(style) { - document.documentElement.appendChild(doc.importNode(style, true)); + doc.documentElement.appendChild(doc.importNode(style, true)); }); }); });