@@ -19,12 +19,11 @@ export default {
19
19
var next = el . nextElementSibling
20
20
if ( next && getAttr ( next , 'v-else' ) !== null ) {
21
21
remove ( next )
22
- this . elseFactory = new FragmentFactory ( next . _context || this . vm , next )
22
+ this . elseEl = next
23
23
}
24
24
// check main block
25
25
this . anchor = createAnchor ( 'v-if' )
26
26
replace ( el , this . anchor )
27
- this . factory = new FragmentFactory ( this . vm , el )
28
27
} else {
29
28
process . env . NODE_ENV !== 'production' && warn (
30
29
'v-if="' + this . expression + '" cannot be ' +
@@ -50,6 +49,10 @@ export default {
50
49
this . elseFrag . remove ( )
51
50
this . elseFrag = null
52
51
}
52
+ // lazy init factory
53
+ if ( ! this . factory ) {
54
+ this . factory = new FragmentFactory ( this . vm , this . el )
55
+ }
53
56
this . frag = this . factory . create ( this . _host , this . _scope , this . _frag )
54
57
this . frag . before ( this . anchor )
55
58
} ,
@@ -59,7 +62,13 @@ export default {
59
62
this . frag . remove ( )
60
63
this . frag = null
61
64
}
62
- if ( this . elseFactory && ! this . elseFrag ) {
65
+ if ( this . elseEl && ! this . elseFrag ) {
66
+ if ( ! this . elseFactory ) {
67
+ this . elseFactory = new FragmentFactory (
68
+ this . elseEl . _context || this . vm ,
69
+ this . elseEl
70
+ )
71
+ }
63
72
this . elseFrag = this . elseFactory . create ( this . _host , this . _scope , this . _frag )
64
73
this . elseFrag . before ( this . anchor )
65
74
}
0 commit comments