Skip to content

Commit afbe254

Browse files
fix: allow get_proxied_value to return original value when error
closes #15546
1 parent c436b6c commit afbe254

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

.changeset/afraid-penguins-battle.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: prevent dev server from throwing errors when attempting to retrieve the proxied value of an iframe's contentWindow

packages/svelte/src/internal/client/proxy.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,18 @@ function update_version(signal, d = 1) {
327327
* @param {any} value
328328
*/
329329
export function get_proxied_value(value) {
330-
if (value !== null && typeof value === 'object' && STATE_SYMBOL in value) {
331-
return value[STATE_SYMBOL];
330+
try {
331+
if (value !== null && typeof value === 'object' && STATE_SYMBOL in value) {
332+
return value[STATE_SYMBOL];
333+
}
334+
} catch (err) {
335+
// the above if check can throw an error if the value in question
336+
// is the contentWindow of an iframe on another domain, in which
337+
// case we want to just return the value (because it's definitely
338+
// not a proxied value) so we don't break any JavaScript interacting
339+
// with that iframe (such as various payment companies client side
340+
// JavaScript libraries interacting with their iframes on the same
341+
// domain)
332342
}
333343

334344
return value;

0 commit comments

Comments
 (0)