Skip to content

Throw if composed stream emits array #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 2 additions & 0 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export function addKeys(
node: VNode,
key: string = Math.random().toString()
): VNode {
if (!node) return;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would throw here too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not meant to be an error check. I added that line to skip falsy children VNodes like null and undefined, which is something @cycle/dom offers.


if (!node.children) {
return { ...node, key: node.key ? node.key : key };
}
Expand Down
6 changes: 5 additions & 1 deletion src/makeSortable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down