Move fragment type check to normalizer (#2462)
Should result in more informative stack traces. Fixes #2461
This commit is contained in:
parent
b2f82e3abc
commit
db277217f8
3 changed files with 53 additions and 27 deletions
|
|
@ -11,8 +11,19 @@ Vnode.normalize = function(node) {
|
|||
}
|
||||
Vnode.normalizeChildren = function(input) {
|
||||
var children = []
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
children[i] = Vnode.normalize(input[i])
|
||||
if (input.length) {
|
||||
var isKeyed = input[0] != null && input[0].key != null
|
||||
// Note: this is a *very* perf-sensitive check.
|
||||
// Fun fact: merging the loop like this is somehow faster than splitting
|
||||
// it, noticeably so.
|
||||
for (var i = 1; i < input.length; i++) {
|
||||
if ((input[i] != null && input[i].key != null) !== isKeyed) {
|
||||
throw new TypeError("Vnodes must either always have keys or never have keys!")
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
children[i] = Vnode.normalize(input[i])
|
||||
}
|
||||
}
|
||||
return children
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue