Skip to content
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
64 changes: 64 additions & 0 deletions render/tests/test-normalizeChildren.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,68 @@ o.spec("normalizeChildren", function() {
])
}).throws(TypeError)
})
o("disallows mixed keys, ending with null", function() {
o(function() {
Vnode.normalizeChildren([
{key: 1},
null,
])
}).throws(TypeError)
})
o("disallows mixed keys, starting with null", function() {
o(function() {
Vnode.normalizeChildren([
{data: 1},
null,
])
}).throws(TypeError)
})
o("disallows mixed keys, ending with undefined", function() {
o(function() {
Vnode.normalizeChildren([
{key: 1},
undefined,
])
}).throws(TypeError)
})
o("disallows mixed keys, starting with undefined", function() {
o(function() {
Vnode.normalizeChildren([
{data: 1},
undefined,
])
}).throws(TypeError)
})
o("disallows mixed keys, ending with false", function() {
o(function() {
Vnode.normalizeChildren([
{key: 1},
false,
])
}).throws(TypeError)
})
o("disallows mixed keys, starting with false", function() {
o(function() {
Vnode.normalizeChildren([
{data: 1},
false,
])
}).throws(TypeError)
})
o("disallows mixed keys, ending with true", function() {
o(function() {
Vnode.normalizeChildren([
{key: 1},
true,
])
}).throws(TypeError)
})
o("disallows mixed keys, starting with true", function() {
o(function() {
Vnode.normalizeChildren([
{data: 1},
true,
])
}).throws(TypeError)
})
})
2 changes: 1 addition & 1 deletion render/vnode.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Vnode.normalizeChildren = function(input) {
for (var i = 1; i < input.length; i++) {
if ((input[i] != null && input[i].key != null) !== isKeyed) {
throw new TypeError(
isKeyed && (input[i] != null || typeof input[i] === "boolean")
isKeyed && (input[i] == null || typeof input[i] === "boolean")
? "In fragments, vnodes must either all have keys or none have keys. You may wish to consider using an explicit keyed empty fragment, m.fragment({key: ...}), instead of a hole."
: "In fragments, vnodes must either all have keys or none have keys."
)
Expand Down