Skip to content

Commit 0b25e2b

Browse files
fix: try catch strict_equals to avoid error accessing STATE_SYMBOL (#13216)
Can error if trying to access something while in a secure context, like iframe, sandboxes, etc. Fixes #13214
1 parent e9dc118 commit 0b25e2b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

.changeset/late-geckos-draw.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: try catch `strict_equals` to avoid error accessing `STATE_SYMBOL`

packages/svelte/src/internal/client/dev/equality.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,13 @@ export function init_array_prototype_warnings() {
7878
* @returns {boolean}
7979
*/
8080
export function strict_equals(a, b, equal = true) {
81-
if ((a === b) !== (get_proxied_value(a) === get_proxied_value(b))) {
82-
w.state_proxy_equality_mismatch(equal ? '===' : '!==');
83-
}
81+
// try-catch needed because this tries to read properties of `a` and `b`,
82+
// which could be disallowed for example in a secure context
83+
try {
84+
if ((a === b) !== (get_proxied_value(a) === get_proxied_value(b))) {
85+
w.state_proxy_equality_mismatch(equal ? '===' : '!==');
86+
}
87+
} catch {}
8488

8589
return (a === b) === equal;
8690
}

0 commit comments

Comments
 (0)