From eb6888e44ce1f31a3bc68240d50a0f8940b84a54 Mon Sep 17 00:00:00 2001 From: narcolepticinsomniac Date: Sun, 26 May 2019 06:12:02 -0400 Subject: [PATCH] Avoid potential transition patch conflicts (#720) 8's fix - closes #706, closes #707 --- content/apply.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/content/apply.js b/content/apply.js index cd30cd1c..c3dbaec3 100644 --- a/content/apply.js +++ b/content/apply.js @@ -346,26 +346,29 @@ const APPLY = (() => { function applyTransitionPatch() { // CSS transition bug workaround: since we insert styles asynchronously, // the browsers, especially Firefox, may apply all transitions on page load - const className = chrome.runtime.id + '-transition-bug-fix'; - const docId = document.documentElement.id ? '#' + document.documentElement.id : ''; - document.documentElement.classList.add(className); const el = styleInjector.createStyle('transition-patch'); // FIXME: this will trigger docRootObserver and cause a resort. We should // move this function into style-injector. document.documentElement.appendChild(el); setStyleContent(el, ` - ${docId}.${CSS.escape(className)}:root * { + :root:not(#\\0):not(#\\0) * { transition: none !important; } `) + .then(afterPaint) .then(() => { - setTimeout(() => { - el.remove(); - document.documentElement.classList.remove(className); - }); + el.remove(); }); } + function afterPaint() { + return new Promise(resolve => { + requestAnimationFrame(() => { + setTimeout(resolve); + }); + }); + } + function orphanCheck(e) { if (e && e.detail.method !== 'orphan') { return;