move the iframe styles in the next animation frame

fixes #461
This commit is contained in:
tophf 2018-08-06 17:33:31 +03:00
parent 2db52c9e2d
commit 1a42e6bf00

View File

@ -419,6 +419,7 @@
function initDocRootObserver() { function initDocRootObserver() {
let lastRestorationTime = 0; let lastRestorationTime = 0;
let restorationCounter = 0; let restorationCounter = 0;
let scheduledSort = false;
let observing = false; let observing = false;
let sorting = false; let sorting = false;
let observer; let observer;
@ -476,8 +477,9 @@
return true; return true;
} }
} }
function sortStyleElements() { function sortStyleElements({force} = {}) {
if (!observing) { if (!observing ||
!force && scheduledSort) {
return; return;
} }
let prevExpected = document.documentElement.lastElementChild; let prevExpected = document.documentElement.lastElementChild;
@ -487,6 +489,12 @@
if (!prevExpected) { if (!prevExpected) {
return; return;
} }
if (!CHROME && !force && window !== top) {
requestAnimationFrame(() => sortStyleElements({force: true}));
scheduledSort = true;
return;
}
scheduledSort = false;
for (const el of styleElements.values()) { for (const el of styleElements.values()) {
if (!isMovable(el)) { if (!isMovable(el)) {
continue; continue;