From 9e192d7e18f8b341f6757a0ca9fc4d0a4c125880 Mon Sep 17 00:00:00 2001 From: Chris Lorenzo Date: Mon, 23 Sep 2024 14:07:10 -0400 Subject: [PATCH] fix #2282: Add Check for Proxy support (#2284) * fix: Add Check for Proxy support * Create quick-mirrors-mix.md --------- Co-authored-by: Ryan Carniato --- .changeset/quick-mirrors-mix.md | 5 +++++ packages/solid/src/reactive/signal.ts | 1 + packages/solid/src/render/component.ts | 5 +++-- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/quick-mirrors-mix.md diff --git a/.changeset/quick-mirrors-mix.md b/.changeset/quick-mirrors-mix.md new file mode 100644 index 000000000..ff86a0100 --- /dev/null +++ b/.changeset/quick-mirrors-mix.md @@ -0,0 +1,5 @@ +--- +"solid-js": patch +--- + +fix #2282: Add Check for Proxy support diff --git a/packages/solid/src/reactive/signal.ts b/packages/solid/src/reactive/signal.ts index b4f3deba9..7811b1bd8 100644 --- a/packages/solid/src/reactive/signal.ts +++ b/packages/solid/src/reactive/signal.ts @@ -30,6 +30,7 @@ import type { FlowComponent, FlowProps } from "../render/index.js"; export const equalFn = (a: T, b: T) => a === b; export const $PROXY = Symbol("solid-proxy"); +export const SUPPORTS_PROXY = typeof Proxy === "function"; export const $TRACK = Symbol("solid-track"); export const $DEVCOMP = Symbol("solid-dev-component"); const signalOptions = { equals: equalFn }; diff --git a/packages/solid/src/render/component.ts b/packages/solid/src/render/component.ts index 5561ac422..f90782f60 100644 --- a/packages/solid/src/render/component.ts +++ b/packages/solid/src/render/component.ts @@ -5,6 +5,7 @@ import { createMemo, devComponent, $PROXY, + SUPPORTS_PROXY, $DEVCOMP, EffectFunction } from "../reactive/signal.js"; @@ -197,7 +198,7 @@ export function mergeProps(...sources: T): MergeProps { sources[i] = typeof s === "function" ? ((proxy = true), createMemo(s as EffectFunction)) : s; } - if (proxy) { + if (SUPPORTS_PROXY && proxy) { return new Proxy( { get(property: string | number | symbol) { @@ -280,7 +281,7 @@ export function splitProps< T extends Record, K extends [readonly (keyof T)[], ...(readonly (keyof T)[])[]] >(props: T, ...keys: K): SplitProps { - if ($PROXY in props) { + if (SUPPORTS_PROXY && $PROXY in props) { const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]); const res = keys.map(k => { return new Proxy(