Skip to content

Commit

Permalink
Stores: fix overwriting underscore property (#1842)
Browse files Browse the repository at this point in the history
* Fix underscore property

* Create metal-chefs-begin.md

---------

Co-authored-by: Ryan Carniato <ryansolid@gmail.com>
  • Loading branch information
morethanwords and ryansolid committed Aug 8, 2023
1 parent 5ed448a commit c2008f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-chefs-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"solid-js": patch
---

Fix underscore property
7 changes: 4 additions & 3 deletions packages/solid/store/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { getListener, batch, DEV, $PROXY, $TRACK, createSignal } from "solid-js"

export const $RAW = Symbol("store-raw"),
$NODE = Symbol("store-node"),
$HAS = Symbol("store-has");
$HAS = Symbol("store-has"),
$SELF = Symbol("store-self");

// debug hooks for devtools
export const DevHooks: { onStoreNodeUpdate: OnStoreNodeUpdate | null } = {
Expand Down Expand Up @@ -143,7 +144,7 @@ export function proxyDescriptor(target: StoreNode, property: PropertyKey) {
}

export function trackSelf(target: StoreNode) {
getListener() && getNode(getNodes(target, $NODE), "_")();
getListener() && getNode(getNodes(target, $NODE), $SELF)();
}

export function ownKeys(target: StoreNode) {
Expand Down Expand Up @@ -233,7 +234,7 @@ export function setProperty(
for (let i = state.length; i < len; i++) (node = nodes[i]) && node.$();
(node = getNode(nodes, "length", len)) && node.$(state.length);
}
(node = nodes._) && node.$();
(node = nodes[$SELF]) && node.$();
}

function mergeStoreNode(state: StoreNode, value: Partial<StoreNode>) {
Expand Down

0 comments on commit c2008f0

Please sign in to comment.