Window.customElements shouldn't change when initial about:blank is replaced with a loaded page?
What is the issue with the HTML Standard?
Seems like https://github.com/whatwg/html/pull/10869 changed the behavior, but I think the old behavior was less surprising for window.customElements users.
https://whatpr.org/html/10869/d745538...9ad774d/custom-elements.html#custom-elements-api
A testcase https://mozilla.pettay.fi/moztests/ce_registry.html Gecko and Blink have the old behavior, Webkit the new.
This was discussed and intentionally changed to make document.customElementRegistry the source of truth.
I don't want to change document.customElementRegistry being the source of truth, but I think the loaded page should inherit registry from initial about:blank. It is, IMO, rather surprising that both documents get their own registries. That breaks window.open() case, if one registers custom element definitions before the page load.
@josepharhar
I wonder what is going wrong with the existing per-document.html test then by the way: https://wpt.fyi/results/custom-elements/registries
That uses some generic framework that attempts to test this, but I guess it does a poor job at it?
Hi, @annevk I'd love to work on this as a contributor.
@ja-y-son
5. I wonder what is going wrong with the existing
per-document.htmltest then by the way: https://wpt.fyi/results/custom-elements/registries That uses some generic framework that attempts to test this, but I guess it does a poor job at it?
Per spec #shared-document-creation-infrastructure step 6 we reuse the inner window when navigating away from initial about:blank. But browsers differentiate between transient/temporary about:blank (window.open(foo).document) and a more permanent / initial navigation to about:blank for which load is fired (w = window.open().document; w.location=foo). I think
https://github.com/whatwg/html/issues/3267 is about that. Note that the spec has no concept of an initial navigation to about:blank, https://github.com/whatwg/html/issues/12778.
We also have custom-elements/revamped-scoped-registry/initial-about-blank.tentative.window.js that is supposed to test this but has the same issue.
I'll try to update object-association.js.
Gecko and Blink have the old behavior, Webkit the new.
WebKit also doesn't seem to associate the registry with the document and rather clears it on window reuse. I believe there are more differences between browsers in regard to what things they reset on the window when it's being reused. https://github.com/whatwg/html/issues/3267#issuecomment-2894496042