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

Commit 04e3d72

Browse files
committed
Merge pull request #298 from webcomponents/wcready
README: Add section on WebComponentsReady
2 parents 5dc9ad1 + 28953cb commit 04e3d72

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,23 @@ Everything in this repository is BSD style license unless otherwise specified.
7171

7272
Copyright (c) 2015 The Polymer Authors. All rights reserved.
7373

74+
## Helper utilities
75+
76+
### `WebComponentsReady`
77+
78+
Under native HTML Imports, `<script>` tags in the main document block the loading of such imports. This is to ensure the imports have loaded and any registered elements in them have been upgraded.
79+
80+
The webcomponents.js and webcomponents-lite.js polyfills parse element definitions and handle their upgrade asynchronously. If prematurely fetching the element from the DOM before it has an opportunity to upgrade, you'll be working with an `HTMLUnknownElement`.
81+
82+
For these situations (or when you need an approximate replacement for the Polymer 0.5 `polymer-ready` behavior), you can use the `WebComponentsReady` event as a signal before interacting with the element. The criteria for this event to fire is all Custom Elements with definitions registered by the time HTML Imports available at load time have loaded have upgraded.
83+
84+
```js
85+
window.addEventListener('WebComponentsReady', function(e) {
86+
// imports are loaded and elements have been registered
87+
console.log('Components are ready');
88+
});
89+
```
90+
7491
## Known Issues
7592

7693
* [Custom element's constructor property is unreliable](#constructor)

0 commit comments

Comments
 (0)