From 1b4516906e2c039f8bec38a2bb438b2ce411c81b Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 24 May 2023 13:51:48 -0300 Subject: [PATCH] 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. --- packages/solid/src/reactive/signal.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/solid/src/reactive/signal.ts b/packages/solid/src/reactive/signal.ts index 9e514b15b..138c800b4 100644 --- a/packages/solid/src/reactive/signal.ts +++ b/packages/solid/src/reactive/signal.ts @@ -82,6 +82,7 @@ export interface SignalState extends SourceMapValue { } export interface Owner { + root?: Owner; owned: Computation[] | null; cleanups: (() => void)[] | null; owner: Owner | null; @@ -145,6 +146,7 @@ export function createRoot(fn: RootFunction, detachedOwner?: typeof Owner) ? { owned: null, cleanups: null, context: null, owner: null } : UNOWNED : { + root: detachedOwner?.root ?? owner?.root, owned: null, cleanups: null, context: null, @@ -1396,6 +1398,7 @@ function createComputation( sourceSlots: null, cleanups: null, value: init, + root: Owner?.root, owner: Owner, context: null, pure