Re: [w3c/webcomponents] Add Scoped CustomElementRegsitry explainer (#865)

justinfagnani commented on this pull request.



> +export class MyElement extends HTMLElement {
+  constructor() {
+    this.attachShadow({mode: 'open', registry});
+  }
+}
+```
+
+### Scoped element creation APIs
+
+Element creation APIs, like `createElement()` and `innerHTML` can be grouped into global API (those on Document or Window) and scoped APIs (those on HTMLElement and ShadowRoot). The scoped APIs have an associated Node that can be used to look up a CustomElementRegistry and thus a scoped definition.
+
+In order to support scoped registries we add new scoped APIs, that were previously only available on `Document`, to `ShadowRoot`:
+
+* `createElement()`
+* `createElementNS()`
+* `importNode()`

`adoptNode` doesn't create nodes or run upgrade steps (https://dom.spec.whatwg.org/#concept-node-adopt) so it doesn't need to find a registry.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/pull/865#discussion_r384021634

Received on Tuesday, 25 February 2020 18:10:04 UTC