fix: guard against `customElements` being unavailable in browser extension contexts (#14933)

fixes #14739
pull/14938/head
Simon H 4 days ago committed by GitHub
parent 34628b9c90
commit 08061c85da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: guard against `customElements` being unavailable in browser extension contexts

@ -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, // Don't compute setters for custom elements while they aren't registered yet,
// because during their upgrade/instantiation they might add more setters. // because during their upgrade/instantiation they might add more setters.
// Instead, fall back to a simple "an object, then set as property" heuristic. // 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) ? get_setters(node).includes(prop)
: value && typeof value === 'object' : value && typeof value === 'object'
) { ) {

Loading…
Cancel
Save