@@ -66,38 +66,41 @@ module.exports = {
66
66
*/
67
67
68
68
update : function ( value ) {
69
- this . realUpdate ( value )
69
+ this . setComponent ( value )
70
70
} ,
71
71
72
72
/**
73
73
* Switch dynamic components. May resolve the component
74
74
* asynchronously, and perform transition based on
75
- * specified transition mode. Accepts an async callback
76
- * which is called when the transition ends. (This is
77
- * exposed for vue-router)
75
+ * specified transition mode. Accepts a few additional
76
+ * arguments specifically for vue-router.
78
77
*
79
78
* @param {String } value
80
- * @param {Function } [cb]
79
+ * @param {Object } data
80
+ * @param {Function } afterBuild
81
+ * @param {Function } afterTransition
81
82
*/
82
83
83
- realUpdate : function ( value , cb ) {
84
+ setComponent : function ( value , data , afterBuild , afterTransition ) {
84
85
this . invalidatePending ( )
85
86
if ( ! value ) {
86
87
// just remove current
87
88
this . unbuild ( )
88
- this . remove ( this . childVM , cb )
89
+ this . remove ( this . childVM , afterTransition )
89
90
this . unsetCurrent ( )
90
91
} else {
91
92
this . resolveCtor ( value , _ . bind ( function ( ) {
92
93
this . unbuild ( )
93
- var newComponent = this . build ( )
94
+ var newComponent = this . build ( data )
95
+ /* istanbul ignore if */
96
+ if ( afterBuild ) afterBuild ( newComponent )
94
97
var self = this
95
98
if ( this . readyEvent ) {
96
99
newComponent . $once ( this . readyEvent , function ( ) {
97
- self . swapTo ( newComponent , cb )
100
+ self . transition ( newComponent , afterTransition )
98
101
} )
99
102
} else {
100
- this . swapTo ( newComponent , cb )
103
+ this . transition ( newComponent , afterTransition )
101
104
}
102
105
} , this ) )
103
106
}
@@ -136,10 +139,11 @@ module.exports = {
136
139
* If keep alive and has cached instance, insert that
137
140
* instance; otherwise build a new one and cache it.
138
141
*
142
+ * @param {Object } [data]
139
143
* @return {Vue } - the created instance
140
144
*/
141
145
142
- build : function ( ) {
146
+ build : function ( data ) {
143
147
if ( this . keepAlive ) {
144
148
var cached = this . cache [ this . ctorId ]
145
149
if ( cached ) {
@@ -151,12 +155,14 @@ module.exports = {
151
155
if ( this . Ctor ) {
152
156
var child = vm . $addChild ( {
153
157
el : el ,
158
+ data : data ,
154
159
template : this . template ,
155
160
// if no inline-template, then the compiled
156
161
// linker can be cached for better performance.
157
162
_linkerCachable : ! this . template ,
158
163
_asComponent : true ,
159
- _host : this . _host
164
+ _host : this . _host ,
165
+ _isRouterView : this . _isRouterView
160
166
} , this . Ctor )
161
167
if ( this . keepAlive ) {
162
168
this . cache [ this . ctorId ] = child
@@ -208,7 +214,7 @@ module.exports = {
208
214
* @param {Function } [cb]
209
215
*/
210
216
211
- swapTo : function ( target , cb ) {
217
+ transition : function ( target , cb ) {
212
218
var self = this
213
219
var current = this . childVM
214
220
this . unsetCurrent ( )
@@ -271,4 +277,4 @@ module.exports = {
271
277
}
272
278
}
273
279
274
- }
280
+ }
0 commit comments