Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Commit

Permalink
Bug 1300753 - Trigger document localization on readystate=complete
Browse files Browse the repository at this point in the history
Revert "Bug 1299184 - Move translation trigger for Gecko to MozBeforeLayout"
This reverts commit 1669cd2.
  • Loading branch information
stasm committed Sep 6, 2016
1 parent aa78c1b commit 7414815
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/runtime/gecko/l20n-chrome-xul.js
Expand Up @@ -2,7 +2,7 @@ import { ChromeLocalizationObserver } from '../../lib/observer/chrome';
import { XULLocalization } from '../../lib/dom/xul';

import { ChromeResourceBundle } from './io';
import { getResourceLinks, createObserve } from './util';
import { XULDocumentReady, getResourceLinks, createObserve } from './util';

Components.utils.import('resource://gre/modules/Services.jsm');
Components.utils.import('resource://gre/modules/L10nRegistry.jsm');
Expand Down Expand Up @@ -63,13 +63,10 @@ function createLocalization(name, resIds) {
document.l10n.set(name, l10n);

if (name === 'main') {
document.addEventListener('MozBeforeLayout', () => {
XULDocumentReady().then(() => {
const rootElem = document.documentElement;
document.l10n.observeRoot(rootElem, l10n);
document.l10n.translateRoot(rootElem, l10n);
}, {
once: true,
passive: true
});
}
}
13 changes: 13 additions & 0 deletions src/runtime/gecko/util.js
Expand Up @@ -5,6 +5,19 @@ export {
documentReady as HTMLDocumentReady, getResourceLinks
} from '../web/util';

export function XULDocumentReady() {
if (document.readyState !== 'uninitialized') {
return Promise.resolve();
}

return new Promise(resolve => {
document.addEventListener('readystatechange', function onrsc() {
document.removeEventListener('readystatechange', onrsc);
resolve();
});
});
}

export function createGetValue(bundles) {
return function (id, args) {
const ctx = contexts.get(bundles[0]);
Expand Down

0 comments on commit 7414815

Please sign in to comment.