Skip to content

Commit d1bd32e

Browse files
fix: allow get_proxied_value to return original value when error (#15577)
* fix: allow get_proxied_value to return original value when error closes #15546 * Update packages/svelte/src/internal/client/proxy.js --------- Co-authored-by: Rich Harris <[email protected]>
1 parent ef98cca commit d1bd32e

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
@@ -366,8 +366,18 @@ function update_version(signal, d = 1) {
366366
* @param {any} value
367367
*/
368368
export function get_proxied_value(value) {
369-
if (value !== null && typeof value === 'object' && STATE_SYMBOL in value) {
370-
return value[STATE_SYMBOL];
369+
try {
370+
if (value !== null && typeof value === 'object' && STATE_SYMBOL in value) {
371+
return value[STATE_SYMBOL];
372+
}
373+
} catch {
374+
// the above if check can throw an error if the value in question
375+
// is the contentWindow of an iframe on another domain, in which
376+
// case we want to just return the value (because it's definitely
377+
// not a proxied value) so we don't break any JavaScript interacting
378+
// with that iframe (such as various payment companies client side
379+
// JavaScript libraries interacting with their iframes on the same
380+
// domain)
371381
}
372382

373383
return value;

0 commit comments

Comments
 (0)