From 1a42e6bf00c22d55c4e3086bc17b661116308804 Mon Sep 17 00:00:00 2001 From: tophf Date: Mon, 6 Aug 2018 17:33:31 +0300 Subject: [PATCH] move the iframe styles in the next animation frame fixes #461 --- content/apply.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/content/apply.js b/content/apply.js index ee8b63cc..4e27cdd4 100644 --- a/content/apply.js +++ b/content/apply.js @@ -419,6 +419,7 @@ function initDocRootObserver() { let lastRestorationTime = 0; let restorationCounter = 0; + let scheduledSort = false; let observing = false; let sorting = false; let observer; @@ -476,8 +477,9 @@ return true; } } - function sortStyleElements() { - if (!observing) { + function sortStyleElements({force} = {}) { + if (!observing || + !force && scheduledSort) { return; } let prevExpected = document.documentElement.lastElementChild; @@ -487,6 +489,12 @@ if (!prevExpected) { return; } + if (!CHROME && !force && window !== top) { + requestAnimationFrame(() => sortStyleElements({force: true})); + scheduledSort = true; + return; + } + scheduledSort = false; for (const el of styleElements.values()) { if (!isMovable(el)) { continue;