Re: [whatwg/dom] Update element adoption logic for scoped registry (PR #1437)

ja-y-son left a comment (whatwg/dom#1437)

@annevk Want to verify that this is the expected behavior from this change on effective gloabl registry. Consider this test case from `adoption.window.js`
```
test(t => {
  const contentDocument = document.body.appendChild(document.createElement('iframe')).contentDocument;
  t.add_cleanup(() => contentDocument.defaultView.frameElement.remove());
  const element = document.createElement('div');
  assert_equals(element.customElementRegistry, customElements);

  const scoped = new CustomElementRegistry();
  const scopedElement = contentDocument.createElement('div', { customElementRegistry: scoped });
  contentDocument.body.appendChild(scopedElement);
  assert_equals(scopedElement.customElementRegistry, scoped);
  scopedElement.appendChild(element);
  assert_equals(element.customElementRegistry, contentDocument.customElementRegistry);
}, "Adoption with global registry into a scoped registry");
```

Given that now we look at the parent's registry's effective global registry, the last assert of the test should probably be 
```
assert_equals(element.customElementRegistry, null);
```
given that the parent is using a scoped registry.
Is this expected? Or we want it to keep getting global registry for this element? It feels a bit odd that it originally has a global registry but after adoption it goes to null registry. Perhaps we should make sure that non-null registry element shouldn't get null registry after adoption (unless there are no global registry available)?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/pull/1437#issuecomment-3609883101
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/pull/1437/c3609883101@github.com>

Received on Thursday, 4 December 2025 03:22:30 UTC