- From: Anne van Kesteren <notifications@github.com>
- Date: Fri, 10 Jul 2026 05:46:16 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/977/4935401092@github.com>
annevk left a comment (whatwg/dom#977)
I found a case where the specification model of creation-time realms falls flat:
```
promise_test(async () => {
const inner = await ready;
const container = inner.document.createElement("div");
container.innerHTML = "<section><b>x</b></section>";
document.body.appendChild(container);
const b = container.querySelector("b");
assert_equals(b.ownerDocument, document, "descendant was adopted into the top-level document");
assertInnerRealm(inner, b, "HTMLElement");
}, "Never-wrapped descendant keeps its creation realm after adoption");
```
Firefox passes all the tests I created in https://github.com/web-platform-tests/wpt/pull/61212 except for this one as also Firefox creates JavaScript wrapper objects lazily. Fixing this properly requires implementations to keep track of the initial node document's realm, though they could do this lazily when a node first gets adopted across the document boundary. On cross-document adoption they would either have to wrap all the nodes or store the creation-realm somewhere.
An alternative would be to actually standardize JavaScript wrappers, but that seems extremely unattractive to me.
@smaug---- @rniwa @mfreed7 would love your input on how we should tackle this.
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/977#issuecomment-4935401092
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/dom/issues/977/4935401092@github.com>
Received on Friday, 10 July 2026 12:46:20 UTC