Skip to content

Commit 5f929b0

Browse files
authored
chore: replace stores' usage of __proto__ with Object.getPrototypeOf (#1043)
`__proto__` is [deprecated](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto) and Deno does not support it.
1 parent 0e6e497 commit 5f929b0

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/solid/store/src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export function isWrappable(obj: any) {
66
return (
77
obj != null &&
88
typeof obj === "object" &&
9-
(obj.__proto__ === Object.prototype || Array.isArray(obj))
9+
(Object.getPrototypeOf(obj) === Object.prototype || Array.isArray(obj))
1010
);
1111
}
1212

packages/solid/store/src/store.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,14 @@ function wrap<T extends StoreNode>(value: T, name?: string): T {
4141

4242
export function isWrappable<T>(obj: T | NotWrappable): obj is T;
4343
export function isWrappable(obj: any) {
44+
let proto;
4445
return (
4546
obj != null &&
4647
typeof obj === "object" &&
47-
(obj[$PROXY] || !obj.__proto__ || obj.__proto__ === Object.prototype || Array.isArray(obj))
48+
(obj[$PROXY] ||
49+
!(proto = Object.getPrototypeOf(obj)) ||
50+
proto === Object.prototype ||
51+
Array.isArray(obj))
4852
);
4953
}
5054

0 commit comments

Comments
 (0)