- From: Joe Pea <notifications@github.com>
- Date: Sat, 10 Feb 2018 23:04:21 +0000 (UTC)
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/webcomponents/issues/716/364703170@github.com>
What happens in `my-foo` from the above example is removed then appended into another tree unrelated to the scope? Does it just continue to work? Or is an error thrown?
> fully composable registry graph where the resolution of a name can be delegated to any registry where the logic can be customized in user-land.
This seems like it could be useful for some sort of framework, but would definitely be nice to have a default (that just looks in the parent scope) so that the end user can just do something perhaps as easy as
```js
const myRegistry = new CustomElementRegistry()
myRegistry.define('my-foo', MyFoo);
this.root = this.attachShadow({mode: 'open', registry: myRegistry})
```
which causes lookup to look in the parent scope (parent shadow root) when the element name is not found in the current registry.
Just tossing in a syntax idea:
```js
this.root = this.attachShadow({mode: 'open', registry: true})
this.root.define('my-foo', MyFoo);
```
or maybe just simply:
```js
this.root = this.attachShadow({mode: 'open'})
this.root.define('my-foo', MyFoo); // creates a registry internally on first use
```
And for advanced use (f.e. defining lookup):
```js
this.root = this.attachShadow({mode: 'open'})
console.log(this.root.registry) // null
this.root.define('my-foo', MyFoo); // creates a registry on first use
console.log(this.root.registry) // CustomElementsRegistry
// ... and for advanced users:
this.root.registry.defineLookup(function() { ... })
```
This way it's easier, yet still configurable for advanced cases.
--
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/issues/716#issuecomment-364703170
Received on Saturday, 10 February 2018 23:04:44 UTC