@@ -117,13 +117,7 @@ export function createPatchFunction (backend) {
117
117
? nodeOps . createElementNS ( vnode . ns , tag )
118
118
: nodeOps . createElement ( tag )
119
119
setScope ( vnode )
120
- if ( Array . isArray ( children ) ) {
121
- for ( i = 0 ; i < children . length ; ++ i ) {
122
- nodeOps . appendChild ( elm , createElm ( children [ i ] , insertedVnodeQueue , true ) )
123
- }
124
- } else if ( isPrimitive ( vnode . text ) ) {
125
- nodeOps . appendChild ( elm , nodeOps . createTextNode ( vnode . text ) )
126
- }
120
+ createChildren ( vnode , children , insertedVnodeQueue )
127
121
if ( isDef ( data ) ) {
128
122
invokeCreateHooks ( vnode , insertedVnodeQueue )
129
123
}
@@ -135,6 +129,16 @@ export function createPatchFunction (backend) {
135
129
return vnode . elm
136
130
}
137
131
132
+ function createChildren ( vnode , children , insertedVnodeQueue ) {
133
+ if ( Array . isArray ( children ) ) {
134
+ for ( let i = 0 ; i < children . length ; ++ i ) {
135
+ nodeOps . appendChild ( vnode . elm , createElm ( children [ i ] , insertedVnodeQueue , true ) )
136
+ }
137
+ } else if ( isPrimitive ( vnode . text ) ) {
138
+ nodeOps . appendChild ( vnode . elm , nodeOps . createTextNode ( vnode . text ) )
139
+ }
140
+ }
141
+
138
142
function isPatchable ( vnode ) {
139
143
while ( vnode . child ) {
140
144
vnode = vnode . child . _vnode
@@ -404,26 +408,31 @@ export function createPatchFunction (backend) {
404
408
if ( isDef ( tag ) ) {
405
409
if ( isDef ( children ) ) {
406
410
const childNodes = nodeOps . childNodes ( elm )
407
- let childrenMatch = true
408
- if ( childNodes . length !== children . length ) {
409
- childrenMatch = false
411
+ // empty element, allow client to pick up and populate children
412
+ if ( ! childNodes . length ) {
413
+ createChildren ( vnode , children , insertedVnodeQueue )
410
414
} else {
411
- for ( let i = 0 ; i < children . length ; i ++ ) {
412
- if ( ! hydrate ( childNodes [ i ] , children [ i ] , insertedVnodeQueue ) ) {
413
- childrenMatch = false
414
- break
415
+ let childrenMatch = true
416
+ if ( childNodes . length !== children . length ) {
417
+ childrenMatch = false
418
+ } else {
419
+ for ( let i = 0 ; i < children . length ; i ++ ) {
420
+ if ( ! hydrate ( childNodes [ i ] , children [ i ] , insertedVnodeQueue ) ) {
421
+ childrenMatch = false
422
+ break
423
+ }
415
424
}
416
425
}
417
- }
418
- if ( ! childrenMatch ) {
419
- if ( process . env . NODE_ENV !== 'production' &&
420
- typeof console !== 'undefined' &&
421
- ! bailed ) {
422
- bailed = true
423
- console . warn ( 'Parent: ' , elm )
424
- console . warn ( 'Mismatching childNodes vs. VNodes: ' , childNodes , children )
426
+ if ( ! childrenMatch ) {
427
+ if ( process . env . NODE_ENV !== 'production' &&
428
+ typeof console !== 'undefined' &&
429
+ ! bailed ) {
430
+ bailed = true
431
+ console . warn ( 'Parent: ' , elm )
432
+ console . warn ( 'Mismatching childNodes vs. VNodes: ' , childNodes , children )
433
+ }
434
+ return false
425
435
}
426
- return false
427
436
}
428
437
}
429
438
if ( isDef ( data ) ) {
0 commit comments