From efd40350ebcd38f5151cf63c7d72bafcdca9db71 Mon Sep 17 00:00:00 2001 From: Xavier Loh Date: Tue, 7 Jun 2022 20:31:22 +0800 Subject: [PATCH] chore: replace stores' usage of `__proto__` with `Object.getPrototypeOf` `__proto__` is [deprecated](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto) and Deno does not support it. --- packages/solid/store/src/server.ts | 2 +- packages/solid/store/src/store.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/solid/store/src/server.ts b/packages/solid/store/src/server.ts index 8cfa6823d..cdd7bd2df 100644 --- a/packages/solid/store/src/server.ts +++ b/packages/solid/store/src/server.ts @@ -6,7 +6,7 @@ export function isWrappable(obj: any) { return ( obj != null && typeof obj === "object" && - (obj.__proto__ === Object.prototype || Array.isArray(obj)) + (Object.getPrototypeOf(obj) === Object.prototype || Array.isArray(obj)) ); } diff --git a/packages/solid/store/src/store.ts b/packages/solid/store/src/store.ts index 3145a74a7..887973f1e 100644 --- a/packages/solid/store/src/store.ts +++ b/packages/solid/store/src/store.ts @@ -41,10 +41,14 @@ function wrap(value: T, name?: string): T { export function isWrappable(obj: T | NotWrappable): obj is T; export function isWrappable(obj: any) { + let proto; return ( obj != null && typeof obj === "object" && - (obj[$PROXY] || !obj.__proto__ || obj.__proto__ === Object.prototype || Array.isArray(obj)) + (obj[$PROXY] || + !(proto = Object.getPrototypeOf(obj)) || + proto === Object.prototype || + Array.isArray(obj)) ); }