@@ -86,27 +86,12 @@ export function createPatchFunction (backend) {
8686
8787 let inPre = 0
8888 function createElm ( vnode , insertedVnodeQueue , parentElm , refElm , nested ) {
89- let i , isReactivated
90- const data = vnode . data
91- vnode . isRootInsert = ! nested
92- if ( isDef ( data ) ) {
93- if ( isDef ( i = data . hook ) && isDef ( i = i . init ) ) {
94- isReactivated = i ( vnode , false /* hydrating */ , parentElm , refElm )
95- }
96- // after calling the init hook, if the vnode is a child component
97- // it should've created a child instance and mounted it. the child
98- // component also has set the placeholder vnode's elm.
99- // in that case we can just return the element and be done.
100- if ( isDef ( i = vnode . child ) ) {
101- initComponent ( vnode , insertedVnodeQueue )
102- if ( isReactivated ) {
103- // unlike a newly created component,
104- // a reactivated keep-alive component doesn't insert itself
105- insert ( parentElm , vnode . child . $el , refElm )
106- }
107- return
108- }
89+ vnode . isRootInsert = ! nested // for transition enter check
90+ if ( createComponent ( vnode , insertedVnodeQueue , parentElm , refElm ) ) {
91+ return
10992 }
93+
94+ const data = vnode . data
11095 const children = vnode . children
11196 const tag = vnode . tag
11297 if ( isDef ( tag ) ) {
@@ -172,6 +157,29 @@ export function createPatchFunction (backend) {
172157 }
173158 }
174159
160+ function createComponent ( vnode , insertedVnodeQueue , parentElm , refElm ) {
161+ let i = vnode . data
162+ if ( isDef ( i ) ) {
163+ const isReactivated = isDef ( vnode . child ) && i . keepAlive
164+ if ( isDef ( i = i . hook ) && isDef ( i = i . init ) ) {
165+ i ( vnode , false /* hydrating */ , parentElm , refElm )
166+ }
167+ // after calling the init hook, if the vnode is a child component
168+ // it should've created a child instance and mounted it. the child
169+ // component also has set the placeholder vnode's elm.
170+ // in that case we can just return the element and be done.
171+ if ( isDef ( vnode . child ) ) {
172+ initComponent ( vnode , insertedVnodeQueue )
173+ if ( isReactivated ) {
174+ // unlike a newly created component,
175+ // a reactivated keep-alive component doesn't insert itself
176+ insert ( parentElm , vnode . elm , refElm )
177+ }
178+ return true
179+ }
180+ }
181+ }
182+
175183 function insert ( parent , elm , ref ) {
176184 if ( parent ) {
177185 nodeOps . insertBefore ( parent , elm , ref )
0 commit comments