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

Commit

Permalink
Bug 1300752 - Put perf markers in translateRootContent
Browse files Browse the repository at this point in the history
  • Loading branch information
stasm committed Sep 6, 2016
1 parent 9e79377 commit aa78c1b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/lib/observer/chrome.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
import { LocalizationObserver } from './base';

function markEnd() {
performance.mark('l20n: end translateRootContent');
performance.measure(
'l20n: translateRootContent',
'l20n: start translateRootContent',
'l20n: end translateRootContent'
);
}

export class ChromeLocalizationObserver extends LocalizationObserver {
translateRootContent(root) {
performance.mark('l20n: start translateRootContent');
const anonChildren = document.getAnonymousNodes(root);
if (!anonChildren) {
return this.translateFragment(root);
return this.translateFragment(root).then(markEnd);
}

return Promise.all(
[root, ...anonChildren].map(node => this.translateFragment(node))
);
).then(markEnd);
}
}

0 comments on commit aa78c1b

Please sign in to comment.