diff --git a/package.json b/package.json index 87bdffb..9e5fcaf 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ }, "dependencies": { "@cycle/run": "^3.0.0", - "snabbdom-selector": "^1.2.0", + "snabbdom-selector": "^1.3.2", "xstream": "^11.0.0" }, "devDependencies": { diff --git a/src/helpers.ts b/src/helpers.ts index 9dea7d4..8f67ecf 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -50,6 +50,8 @@ export function addKeys( node: VNode, key: string = Math.random().toString() ): VNode { + if (!node) return; + if (!node.children) { return { ...node, key: node.key ? node.key : key }; } diff --git a/src/makeSortable.ts b/src/makeSortable.ts index 4a6dabe..5ec7b3a 100644 --- a/src/makeSortable.ts +++ b/src/makeSortable.ts @@ -37,7 +37,11 @@ function augmentStartDistance( } function moreThanOneChild(node: VNode) { - return !node.children || node.children.length > 1; + if (Array.isArray(node)) { + throw new Error('Composed stream should emit VNodes not arrays'); + } + + return !node || node.children.length > 1; } function notMoreThanOneChild(node: VNode) {