Skip to content

Commit

Permalink
chore: replace stores' usage of __proto__ with `Object.getPrototype…
Browse files Browse the repository at this point in the history
…Of` (#1043)

`__proto__` is [deprecated](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto) and Deno does not support it.
  • Loading branch information
otonashixav committed Jun 7, 2022
1 parent 0e6e497 commit 5f929b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/solid/store/src/server.ts
Expand Up @@ -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))
);
}

Expand Down
6 changes: 5 additions & 1 deletion packages/solid/store/src/store.ts
Expand Up @@ -41,10 +41,14 @@ function wrap<T extends StoreNode>(value: T, name?: string): T {

export function isWrappable<T>(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))
);
}

Expand Down

0 comments on commit 5f929b0

Please sign in to comment.