From 24a75e935a3864e68b26e4879debcff80cd4586e Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Sat, 2 Dec 2023 19:35:47 +0100 Subject: [PATCH] Allow specification of base for selector --- packages/html2/src/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/html2/src/index.ts b/packages/html2/src/index.ts index 9633941..b61f911 100644 --- a/packages/html2/src/index.ts +++ b/packages/html2/src/index.ts @@ -94,14 +94,14 @@ export class Widget implements EventTarget { } set parent(p: string | ParentNode | null) { - if (typeof p === 'string') { - p = document.querySelector(p); - } - this._parent.value = p; + this.setParent(p); } - setParent(p: string | ParentNode | null): this { - this.parent = p; + setParent(p: string | ParentNode | null, wrt: ParentNode = document): this { + if (typeof p === 'string') { + p = wrt.querySelector(p); + } + this._parent.value = p; return this; }