diff --git a/packages/html2/src/index.ts b/packages/html2/src/index.ts index 9401169..9633941 100644 --- a/packages/html2/src/index.ts +++ b/packages/html2/src/index.ts @@ -39,7 +39,14 @@ export class Widget implements EventTarget { dataflow { const oldNode = this.node.value; - const newNode = template`${this.nodeGenerator(template)}`.node(); + + const fragments = template`${this.nodeGenerator(template)}`; + const newNodes = fragments.nodes(); + if (newNodes.length > 1) { + throw new Error(`@syndicate-lang/html2: Multiple nodes returned from template: ${fragments.toString()}`); + } + const newNode = newNodes[0]; + if (oldNode !== newNode) { if (oldNode !== null) { for (const [type, cbs] of this.callbacks.entries()) {