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

Use better words about the bundles and the loader#693

Merged
notwaldorf merged 2 commits into
v1from
words-about-the-loader
Feb 24, 2017
Merged

Use better words about the bundles and the loader#693
notwaldorf merged 2 commits into
v1from
words-about-the-loader

Conversation

@notwaldorf
Copy link
Copy Markdown
Contributor

I cleaned up the "Releases" section into a (maybe clearer) "How to use section", since we have a lot a build artifacts now and they're a bit intimidating.

👀 @kevinpschaaf

Comment thread README.md
- **Custom Elements**: allows authors to define their own custom tags ([spec](https://w3c.github.io/webcomponents/spec/custom/)).
- **HTML Imports**: a way to include and reuse HTML documents via other HTML documents ([spec](https://w3c.github.io/webcomponents/spec/imports/)).
- **Shadow DOM**: provides encapsulation by hiding DOM subtrees under shadow roots ([spec](https://w3c.github.io/webcomponents/spec/shadow/)).

Copy link
Copy Markdown
Contributor

@kevinpschaaf kevinpschaaf Feb 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List the other minor polyfills this provides under an "Other minor polyfills" bullet?

  • HTMLTemplateElement
  • Promise
  • unresolved attribute shim for ::unresolved
  • Event, CustomEvent, MouseEvent constructors
  • Object.assign, Array.from

Comment thread README.md Outdated
- `webcomponents-lite` -- all of the polyfills: HTML Imports, Custom Elements, Shady DOM/CSS and generic platform polyfills (such as Template, ES6 Promise, Constructable events, etc.) (needed by Internet Explorer 11)

If you are only targetting a specific browser, you can just use the bundle that's
needed by it; alternatively, if you're using server-side rendering, you can
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest changing

if you're using server-side rendering, you can...

to

if your server is capable of serving different assets based on user agent, you can...

The term "server-side rendering" has a different meaning.

Comment thread README.md Outdated
window.addEventListener('WebComponentsReady', function() {
var s = document.createElement('script');
s.src = 'lazy-element.js';
document.head.appendChild(s);
Copy link
Copy Markdown
Contributor

@kevinpschaaf kevinpschaaf Feb 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... not sure the example is showing a particularly idiomatic use case (dynamically appending script after WCR?), thus might be hard to understand why WCR is important. How about:

<!-- Load polyfills; note that "loader" will load these async -->
<script src="bower_components/webcomponentsjs/webcomponents-loader.js"></script>

<!-- Load a custom element definition via HTMLImports -->
<link rel="import" href="my-element.html">

<!-- Use the custom element -->
<my-element></my-element>

<!-- Interact with the upgraded element -->
<script>
  window.addEventListener('WebComponentsReady', function() {
    // At this point we are guaranteed that all required polyfills have loaded,
    // all HTML imports have loaded, and all defined custom elements have upgraded
    let MyElement = customElements.get('my-element');
    let element = document.querySelector('my-element');
    console.assert(element instanceof MyElement);  // 👍
    element.someAPI(); // 👍
  });
</script>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah that's waaaay better. Thanks!

Comment thread README.md Outdated
- `webcomponents-hi-ce` -- HTML Imports and Custom Elements (needed by Safari 10)
- `webcomponents-hi-sd-ce` -- HTML Imports, Custom Elements and Shady DOM/CSS (needed by Safari 9, Firefox, Edge)
- `webcomponents-sd-ce` -- Custom Elements and Shady DOM/CSS (no HTML Imports)
- `webcomponents-lite` -- all of the polyfills: HTML Imports, Custom Elements, Shady DOM/CSS and generic platform polyfills (such as Template, ES6 Promise, Constructable events, etc.) (needed by Internet Explorer 11)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add .js extensions so it's clear these are filenames?

Comment thread README.md Outdated
## `webcomponents-loader.js`

Alternatively, this repo also comes with `webcomponents-loader.js`, a client-side
loader that dynamically loads the correct polyfill bundle, using feature detection.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/correct polyfill bundle/minimum polyfill bundle

Comment thread README.md Outdated
- `webcomponents-hi-ce` -- HTML Imports and Custom Elements (needed by Safari 10)
- `webcomponents-hi-sd-ce` -- HTML Imports, Custom Elements and Shady DOM/CSS (needed by Safari 9, Firefox, Edge)
- `webcomponents-sd-ce` -- Custom Elements and Shady DOM/CSS (no HTML Imports)
- `webcomponents-lite` -- all of the polyfills: HTML Imports, Custom Elements, Shady DOM/CSS and generic platform polyfills (such as Template, ES6 Promise, Constructable events, etc.) (needed by Internet Explorer 11)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes, just realized that we might need to tweak loader so that webcomponents-lite is loaded for Edge too -- let's double-check tomorrow. Technically Edge has Template but their impl is pretty busted (we fix it up in the Template polyfill). Since most testing is using webcomponents-lite this hasn't come up in tests. 😩

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... I think we need to add this check, and if it returns false need to load template polyfill (pf bundle):

(document.createDocumentFragment().cloneNode() instanceof DocumentFragment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@notwaldorf
Copy link
Copy Markdown
Contributor Author

@kevinpschaaf copy pasted all your changes, basically :)

@notwaldorf
Copy link
Copy Markdown
Contributor Author

Thanks!

@notwaldorf notwaldorf merged commit 1d03bdb into v1 Feb 24, 2017
@notwaldorf notwaldorf deleted the words-about-the-loader branch February 24, 2017 22:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants