Skip to content

Commit 94929af

Browse files
MrFoxProryansolid
andauthored
fix wrapping of object with null prototype (#2286)
* fix wrapping object with null prototype * Create yellow-rings-report.md --------- Co-authored-by: Ryan Carniato <ryansolid@gmail.com>
1 parent 9697c94 commit 94929af

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

.changeset/yellow-rings-report.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"solid-js": patch
3+
---
4+
5+
fix wrapping of object with `null` prototype

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)