From c76db34c045877235334dcf04679e018108c946e Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 28 Nov 2023 21:20:45 -0500 Subject: [PATCH] more --- packages/svelte/src/internal/client/magic.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/svelte/src/internal/client/magic.js b/packages/svelte/src/internal/client/magic.js index 76647aeae..3349a64eb 100644 --- a/packages/svelte/src/internal/client/magic.js +++ b/packages/svelte/src/internal/client/magic.js @@ -6,6 +6,10 @@ import { effect_active, get, set, increment, source } from './runtime.js'; export const MAGIC_SYMBOL = Symbol(); export const MAGIC_EACH_SYMBOL = Symbol(); +const object_prototype = Object.prototype; +const array_prototype = Array.prototype; +const get_prototype_of = Object.getPrototypeOf; + /** * @template {MagicObject} T * @param {T} value @@ -24,7 +28,12 @@ export function magic(value) { */ function wrap(value, parent) { if (value && typeof value === 'object') { - return proxy(value, parent); + const prototype = get_prototype_of(value); + + // TODO handle Map and Set as well + if (prototype === object_prototype || prototype === array_prototype) { + return proxy(value, parent); + } } return value;