Bug 40150: Prevent uncaught error on multiple attempts to 'define' on 'CustomElementsRegistry' in islands.ts

If the name is already in use, we just return.

It might make sense to have a console.debug() or similar to notify
developers that this is happening. Open for other opinions.

To test:
1) Apply the first patch which adds an additional hydrate call in main-container.inc
2) Go to acqui/acqui-home.pl
3) Verify that you see this error in the dev tool's console tab:
Uncaught (in promise) NotSupportedError: Failed to execute 'define' on 'CustomElementRegistry': the name "acquisitions-menu" has already been used with this registry
4) Apply the second patch
5) Run `yarn js:build` in ktd (assuming ktd).
6) Reload the page without cached assets (Ctrl/Cmd + Shift + R) and verify that the uncaught error is gone.
7) Sign off.

There's an additional problem here I (and probably you) noticed. But that's unrelated to this bug.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit e152b1be08)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Paul Derscheid 2025-06-16 17:29:41 +02:00
parent 15be16d017
commit f60f9c624e
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 4 additions and 0 deletions

View File

@ -107,6 +107,10 @@ export function hydrate(): void {
}
const component = await importFn();
if (customElements.get(name)) {
return;
}
customElements.define(
name,
defineCustomElement(component as any, {