Repair relationship between ValueWidget and Widget constructors

This commit is contained in:
Tony Garnock-Jones 2024-05-29 16:31:20 +02:00
parent d008cc3f94
commit 830652d71c
1 changed files with 6 additions and 3 deletions

View File

@ -34,14 +34,17 @@ export class Widget implements EventTarget {
constructor (arg0: ChildNode | NodeGenerator | string | HTMLTemplateElement, data?: object) {
let nodeGenerator: NodeGenerator;
if (data === void 0) {
if (typeof data === 'object') {
nodeGenerator = templateGenerator(arg0 as (string | HTMLTemplateElement), data);
} else {
// `data` is either undefined or "garbage" e.g. a string given to us by
// ValueWidget's constructor.
if (typeof arg0 === 'function') {
nodeGenerator = arg0 as NodeGenerator;
} else {
nodeGenerator = () => [arg0 as ChildNode];
}
} else {
nodeGenerator = templateGenerator(arg0 as (string | HTMLTemplateElement), data);
}
this.facet = Turn.activeFacet;