- From: Lars den Bakker <notifications@github.com>
- Date: Fri, 21 Feb 2020 12:39:16 -0800
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Friday, 21 February 2020 20:39:28 UTC
> No, it will use the registry from the shadow root it's currently in. Moving elements between scopes is very, very rare.
I mean a situation like this:
```js
import { ElementA } from './element-a.js';
import { ElementB } from './element-b.js';
const divA = document.body.appendChild(document.createElement('div'));
const divB = document.body.appendChild(document.createElement('div'));
divA.attachShadow({
mode: 'open',
registry: new CustomElementRegistry({
definitions: { 'my-element': ElementA },
}),
});
divB.attachShadow({
mode: 'open',
registry: new CustomElementRegistry({
definitions: { 'my-element': ElementB },
}),
});
divA.shadowRoot.innerHTML = '<my-element></my-element>';
const myElement = divA.shadowRoot.querySelector('my-element');
console.assert(myElement.constructor === elementA);
divB.shadowRoot.appendChild(myElement);
console.assert(myElement.constructor === elementA);
```
So even after moving shadow roots, the constructor stays the same.
--
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#issuecomment-589825963
Received on Friday, 21 February 2020 20:39:28 UTC