Skip to content

Commit

Permalink
Avoid potential transition patch conflicts (#720)
Browse files Browse the repository at this point in the history
8's fix - closes #706, closes #707
  • Loading branch information
narcolepticinsomniac authored May 26, 2019
1 parent 8906cbb commit eb6888e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions content/apply.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit eb6888e

Please sign in to comment.