diff --git a/packages/html2/src/index.ts b/packages/html2/src/index.ts index 08ff25d..27a23f9 100644 --- a/packages/html2/src/index.ts +++ b/packages/html2/src/index.ts @@ -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;