Error check in case of multiple nodes generated
This commit is contained in:
parent
cfd2b69943
commit
ae2c113325
|
@ -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()) {
|
||||
|
|
Loading…
Reference in New Issue