Skip to content

Commit 1b45169

Browse files
committed
feat: add Owner.root shallow property that stores the root owner
The root property can be used to store referentially unique object accessible in the owner tree. This property is copied to child owners and computations.
1 parent f99dd04 commit 1b45169

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

packages/solid/src/reactive/signal.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export interface SignalState<T> extends SourceMapValue {
8282
}
8383

8484
export interface Owner {
85+
root?: Owner;
8586
owned: Computation<any>[] | null;
8687
cleanups: (() => void)[] | null;
8788
owner: Owner | null;
@@ -145,6 +146,7 @@ export function createRoot<T>(fn: RootFunction<T>, detachedOwner?: typeof Owner)
145146
? { owned: null, cleanups: null, context: null, owner: null }
146147
: UNOWNED
147148
: {
149+
root: detachedOwner?.root ?? owner?.root,
148150
owned: null,
149151
cleanups: null,
150152
context: null,
@@ -1396,6 +1398,7 @@ function createComputation<Next, Init = unknown>(
13961398
sourceSlots: null,
13971399
cleanups: null,
13981400
value: init,
1401+
root: Owner?.root,
13991402
owner: Owner,
14001403
context: null,
14011404
pure

0 commit comments

Comments
 (0)