Skip to content

Commit

Permalink
feat: add Owner.document shallow property
Browse files Browse the repository at this point in the history
The document property can be used to store document instances other than window.document. This property is copied to child owners and computations.
  • Loading branch information
pedro00dk committed May 24, 2023
1 parent f99dd04 commit 600298f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/solid/src/reactive/signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export interface Owner {
context: any | null;
sourceMap?: SourceMapValue[];
name?: string;
document?: Document;
}

export interface Computation<Init, Next extends Init = Init> extends Owner {
Expand Down Expand Up @@ -148,7 +149,8 @@ export function createRoot<T>(fn: RootFunction<T>, detachedOwner?: typeof Owner)
owned: null,
cleanups: null,
context: null,
owner: detachedOwner === undefined ? owner : detachedOwner
owner: detachedOwner === undefined ? owner : detachedOwner,
document: detachedOwner?.document ?? owner?.document
},
updateFn = unowned
? "_SOLID_DEV_"
Expand Down Expand Up @@ -1397,6 +1399,7 @@ function createComputation<Next, Init = unknown>(
cleanups: null,
value: init,
owner: Owner,
document: Owner?.document,
context: null,
pure
};
Expand Down

0 comments on commit 600298f

Please sign in to comment.