diff --git a/.changeset/forty-books-taste.md b/.changeset/forty-books-taste.md new file mode 100644 index 0000000000..e2474c635f --- /dev/null +++ b/.changeset/forty-books-taste.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: guard against `customElements` being unavailable in browser extension contexts diff --git a/packages/svelte/src/internal/client/dom/elements/attributes.js b/packages/svelte/src/internal/client/dom/elements/attributes.js index 6656532986..a2fffe8696 100644 --- a/packages/svelte/src/internal/client/dom/elements/attributes.js +++ b/packages/svelte/src/internal/client/dom/elements/attributes.js @@ -221,7 +221,10 @@ export function set_custom_element_data(node, prop, value) { // Don't compute setters for custom elements while they aren't registered yet, // because during their upgrade/instantiation they might add more setters. // Instead, fall back to a simple "an object, then set as property" heuristic. - setters_cache.has(node.nodeName) || customElements.get(node.tagName.toLowerCase()) + setters_cache.has(node.nodeName) || + // customElements may not be available in browser extension contexts + !customElements || + customElements.get(node.tagName.toLowerCase()) ? get_setters(node).includes(prop) : value && typeof value === 'object' ) {