Skip to content

Commit

Permalink
Bug 1455048 - Revert the workaround added to Fluent for microtasks bu…
Browse files Browse the repository at this point in the history
…g. r=mossop

MozReview-Commit-ID: AFpNRPfJpm7
  • Loading branch information
Zibi Braniecki committed Apr 18, 2018
1 parent 4f11968 commit 89b79fa
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions intl/l10n/l10n.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,26 @@
* Polyfill for document.ready polyfill.
* See: https://github.com/whatwg/html/issues/127 for details.
*
* XXX: The callback is a temporary workaround for bug 1193394. Once Promises in Gecko
* start beeing a microtask and stop pushing translation post-layout, we can
* remove it and start using the returned Promise again.
*
* @param {Function} callback - function to be called when the document is ready.
* @returns {Promise}
*/
function documentReady(callback) {
function documentReady() {
if (document.contentType === "application/vnd.mozilla.xul+xml") {
// XUL
return new Promise(
resolve => document.addEventListener(
"MozBeforeInitialXULLayout", () => {
resolve(callback());
}, { once: true }
"MozBeforeInitialXULLayout", resolve, { once: true }
)
);
}

// HTML
const rs = document.readyState;
if (rs === "interactive" || rs === "completed") {
return Promise.resolve(callback);
return Promise.resolve();
}
return new Promise(
resolve => document.addEventListener(
"readystatechange", () => {
resolve(callback());
}, { once: true }
"readystatechange", resolve, { once: true }
)
);
}
Expand All @@ -58,7 +49,7 @@
// trigger first context to be fetched eagerly
document.l10n.ctxs.touchNext();

document.l10n.ready = documentReady(() => {
document.l10n.ready = documentReady().then(() => {
document.l10n.registerObservers();
document.l10n.connectRoot(document.documentElement);
return document.l10n.translateRoots();
Expand Down

0 comments on commit 89b79fa

Please sign in to comment.