Skip to content

Commit 600298f

Browse files
committed
feat: add Owner.document shallow property
The document property can be used to store document instances other than window.document. This property is copied to child owners and computations.
1 parent f99dd04 commit 600298f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/solid/src/reactive/signal.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export interface Owner {
8888
context: any | null;
8989
sourceMap?: SourceMapValue[];
9090
name?: string;
91+
document?: Document;
9192
}
9293

9394
export interface Computation<Init, Next extends Init = Init> extends Owner {
@@ -148,7 +149,8 @@ export function createRoot<T>(fn: RootFunction<T>, detachedOwner?: typeof Owner)
148149
owned: null,
149150
cleanups: null,
150151
context: null,
151-
owner: detachedOwner === undefined ? owner : detachedOwner
152+
owner: detachedOwner === undefined ? owner : detachedOwner,
153+
document: detachedOwner?.document ?? owner?.document
152154
},
153155
updateFn = unowned
154156
? "_SOLID_DEV_"
@@ -1397,6 +1399,7 @@ function createComputation<Next, Init = unknown>(
13971399
cleanups: null,
13981400
value: init,
13991401
owner: Owner,
1402+
document: Owner?.document,
14001403
context: null,
14011404
pure
14021405
};

0 commit comments

Comments
 (0)