@@ -66,38 +66,41 @@ module.exports = {
6666 */
6767
6868 update : function ( value ) {
69- this . realUpdate ( value )
69+ this . setComponent ( value )
7070 } ,
7171
7272 /**
7373 * Switch dynamic components. May resolve the component
7474 * 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.
7877 *
7978 * @param {String } value
80- * @param {Function } [cb]
79+ * @param {Object } data
80+ * @param {Function } afterBuild
81+ * @param {Function } afterTransition
8182 */
8283
83- realUpdate : function ( value , cb ) {
84+ setComponent : function ( value , data , afterBuild , afterTransition ) {
8485 this . invalidatePending ( )
8586 if ( ! value ) {
8687 // just remove current
8788 this . unbuild ( )
88- this . remove ( this . childVM , cb )
89+ this . remove ( this . childVM , afterTransition )
8990 this . unsetCurrent ( )
9091 } else {
9192 this . resolveCtor ( value , _ . bind ( function ( ) {
9293 this . unbuild ( )
93- var newComponent = this . build ( )
94+ var newComponent = this . build ( data )
95+ /* istanbul ignore if */
96+ if ( afterBuild ) afterBuild ( newComponent )
9497 var self = this
9598 if ( this . readyEvent ) {
9699 newComponent . $once ( this . readyEvent , function ( ) {
97- self . swapTo ( newComponent , cb )
100+ self . transition ( newComponent , afterTransition )
98101 } )
99102 } else {
100- this . swapTo ( newComponent , cb )
103+ this . transition ( newComponent , afterTransition )
101104 }
102105 } , this ) )
103106 }
@@ -136,10 +139,11 @@ module.exports = {
136139 * If keep alive and has cached instance, insert that
137140 * instance; otherwise build a new one and cache it.
138141 *
142+ * @param {Object } [data]
139143 * @return {Vue } - the created instance
140144 */
141145
142- build : function ( ) {
146+ build : function ( data ) {
143147 if ( this . keepAlive ) {
144148 var cached = this . cache [ this . ctorId ]
145149 if ( cached ) {
@@ -151,12 +155,14 @@ module.exports = {
151155 if ( this . Ctor ) {
152156 var child = vm . $addChild ( {
153157 el : el ,
158+ data : data ,
154159 template : this . template ,
155160 // if no inline-template, then the compiled
156161 // linker can be cached for better performance.
157162 _linkerCachable : ! this . template ,
158163 _asComponent : true ,
159- _host : this . _host
164+ _host : this . _host ,
165+ _isRouterView : this . _isRouterView
160166 } , this . Ctor )
161167 if ( this . keepAlive ) {
162168 this . cache [ this . ctorId ] = child
@@ -208,7 +214,7 @@ module.exports = {
208214 * @param {Function } [cb]
209215 */
210216
211- swapTo : function ( target , cb ) {
217+ transition : function ( target , cb ) {
212218 var self = this
213219 var current = this . childVM
214220 this . unsetCurrent ( )
@@ -271,4 +277,4 @@ module.exports = {
271277 }
272278 }
273279
274- }
280+ }
0 commit comments