Skip to content

Commit 9c209d9

Browse files
committed
fix wrapping object with null prototype
1 parent e4b2c66 commit 9c209d9

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

packages/solid/store/src/mutable.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ function wrap<T extends StoreNode>(value: T): T {
9797

9898
const proto = Object.getPrototypeOf(value);
9999
const isClass =
100+
proto !== null &&
100101
value !== null &&
101102
typeof value === "object" &&
102103
!Array.isArray(value) &&

packages/solid/store/test/mutable.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import { createRoot, createSignal, createMemo, batch, createEffect } from "../..
22
import { Accessor, Setter } from "../../types";
33
import { createMutable, unwrap, $RAW } from "../src";
44

5+
test("Object.create(null) is allowed", () => {
6+
const user = createMutable(Object.assign(Object.create(null), { name: "John" }));
7+
expect(user.name).toBe("John");
8+
});
9+
510
describe("State Mutability", () => {
611
test("Setting a property", () => {
712
const user = createMutable({ name: "John" });

0 commit comments

Comments
 (0)