Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
fire WebComponentsReady event without delay
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Aug 27, 2013
1 parent 448257d commit 3ef94da
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,22 @@
// bootstrap parsing

function bootstrap() {
// go async so call stack can unwind
setTimeout(function() {
// parse document
CustomElements.parser.parse(document);
// one more pass before register is 'live'
CustomElements.upgradeDocument(document);
// set internal 'ready' flag, now document.register will trigger
// synchronous upgrades
CustomElements.ready = true;
// capture blunt profiling data
CustomElements.readyTime = Date.now();
if (window.HTMLImports) {
CustomElements.elapsed = CustomElements.readyTime - HTMLImports.readyTime;
}
// notify the system that we are bootstrapped
document.body.dispatchEvent(
new CustomEvent('WebComponentsReady', {bubbles: true})
);
}, 0);
// parse document
CustomElements.parser.parse(document);
// one more pass before register is 'live'
CustomElements.upgradeDocument(document);
// set internal 'ready' flag, now document.register will trigger
// synchronous upgrades
CustomElements.ready = true;
// capture blunt profiling data
CustomElements.readyTime = Date.now();
if (window.HTMLImports) {
CustomElements.elapsed = CustomElements.readyTime - HTMLImports.readyTime;
}
// notify the system that we are bootstrapped
document.body.dispatchEvent(
new CustomEvent('WebComponentsReady', {bubbles: true})
);
}

// CustomEvent shim for IE
Expand Down

0 comments on commit 3ef94da

Please sign in to comment.