From 71ea723728e13aa959c3796f7947f232be77c4d4 Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 16 Mar 2017 15:47:58 +0300 Subject: [PATCH] Fixup 59e0f3f4: explicitly list our functions in self-destruct Seems simpler and more robust. Otherwise Chrome spams console warnings about its webkit* aliases we touch. --- apply.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/apply.js b/apply.js index 6e6d2e40..2d4bc1fb 100644 --- a/apply.js +++ b/apply.js @@ -321,14 +321,24 @@ function initObserver() { iframeObserver.disconnect(); // we can destroy global functions in this context to free up memory - var globals = Object.keys(window); - for (var i = 0, len = globals.length; i < len; i++) { - var key = globals[i]; - var obj = window[key]; - if (typeof obj == 'function' && !/native code/.test(obj)) { - window[key] = null; - } - } + [ + 'addDocumentStylesToAllIFrames', + 'addDocumentStylesToIFrame', + 'addStyleElement', + 'addStyleToIFrameSrcDoc', + 'applyOnMessage', + 'applySections', + 'applyStyles', + 'disableAll', + 'getDynamicIFrames', + 'iframeIsDynamic', + 'iframeIsLoadingSrcDoc', + 'initObserver', + 'removeStyle', + 'replaceAll', + 'requestStyles', + 'retireStyle' + ].forEach(fn => window[fn] = null); // we can destroy global variables g_styleElements = iframeObserver = retiredStyleIds = null;