Skip to content
This repository was archived by the owner on Sep 20, 2019. It is now read-only.

Commit 68ef957

Browse files
author
Steven Orvell
committed
Adds a window.WebComponents global. Existence of this global indicates that the WebComponentsReady event will be fired when polyfills are ready. After the event fires WebComonents.ready is set to true. This enables testing environments like web-component-tester to more easily determine if they should wait for the WebComponentsReady event before starting.
1 parent ca1f5b0 commit 68ef957

13 files changed

+87
-78
lines changed

entrypoints/webcomponents-sd-ce-index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ import '../bower_components/shadycss/entrypoints/scoping-shim.js'
2121
// NOTE: this is a load-bearing IIFE for Closure
2222
(function() {
2323
let document = window.document;
24+
// global for (1) existence means `WebComponentsReady` will file,
25+
// (2) WebComponents.ready == true means event has fired.
26+
window.WebComponents = window.WebComponents || {};
2427

2528
function fire() {
2629
requestAnimationFrame(() => {
27-
document.querySelector('script[src*="webcomponents"]').webComponentsReady = true;
30+
window.WebComponents.ready = true;
2831
window.document.dispatchEvent(new CustomEvent('WebComponentsReady', { bubbles: true }));
2932
})
3033
}

src/post-polyfill.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
var customElements = window['customElements'];
1616
var HTMLImports = window['HTMLImports'];
17+
// global for (1) existence means `WebComponentsReady` will file,
18+
// (2) WebComponents.ready == true means event has fired.
19+
window.WebComponents = window.WebComponents || {};
1720

1821
if (customElements && customElements['polyfillWrapFlushCallback']) {
1922
// Here we ensure that the public `HTMLImports.whenReady`
@@ -50,7 +53,7 @@
5053

5154
HTMLImports['whenReady'](function() {
5255
requestAnimationFrame(function() {
53-
document.querySelector('script[src*="webcomponents"]').webComponentsReady = true;
56+
window.WebComponents.ready = true;
5457
document.dispatchEvent(new CustomEvent('WebComponentsReady', {bubbles: true}));
5558
});
5659
});

webcomponents-hi-ce.js

Lines changed: 25 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webcomponents-hi-ce.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webcomponents-hi-sd-ce.js

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webcomponents-hi-sd-ce.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webcomponents-hi.js

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webcomponents-hi.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webcomponents-lite.js

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webcomponents-lite.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)