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

Commit 5499edd

Browse files
committed
Refine boot logic; should address issue #68
1 parent e269681 commit 5499edd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/boot.js

+9
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,17 @@ if (typeof window.CustomEvent !== 'function') {
4040
};
4141
}
4242

43+
// When loading at readyState complete time, boot custom elements immediately.
44+
// If relevant, HTMLImports must already be loaded.
4345
if (document.readyState === 'complete') {
4446
bootstrap();
47+
// When loading at readyState interactive time, bootstrap only if HTMLImports
48+
// are not pending. Also avoid IE as the semantics of this state are unreliable.
49+
} else if (document.readyState === 'interactive' && !window.attachEvent &&
50+
(!window.HTMLImports || window.HTMLImports.ready)) {
51+
bootstrap();
52+
// When loading at other readyStates, wait for the appropriate DOM event to
53+
// bootstrap.
4554
} else {
4655
var loadEvent = window.HTMLImports ? 'HTMLImportsLoaded' : 'DOMContentLoaded';
4756
window.addEventListener(loadEvent, bootstrap);

0 commit comments

Comments
 (0)