Skip to content

Commit 08061c8

Browse files
authored
fix: guard against customElements being unavailable in browser extension contexts (#14933)
fixes #14739
1 parent 34628b9 commit 08061c8

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.changeset/forty-books-taste.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: guard against `customElements` being unavailable in browser extension contexts

packages/svelte/src/internal/client/dom/elements/attributes.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,10 @@ export function set_custom_element_data(node, prop, value) {
221221
// Don't compute setters for custom elements while they aren't registered yet,
222222
// because during their upgrade/instantiation they might add more setters.
223223
// Instead, fall back to a simple "an object, then set as property" heuristic.
224-
setters_cache.has(node.nodeName) || customElements.get(node.tagName.toLowerCase())
224+
setters_cache.has(node.nodeName) ||
225+
// customElements may not be available in browser extension contexts
226+
!customElements ||
227+
customElements.get(node.tagName.toLowerCase())
225228
? get_setters(node).includes(prop)
226229
: value && typeof value === 'object'
227230
) {

0 commit comments

Comments
 (0)