File tree Expand file tree Collapse file tree 4 files changed +14
-2
lines changed Expand file tree Collapse file tree 4 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ class Router {
54
54
55
55
// state
56
56
this . _started = false
57
+ this . _startCb = null
57
58
this . _currentRoute = { }
58
59
this . _currentTransition = null
59
60
this . _previousTransition = null
Original file line number Diff line number Diff line change @@ -109,15 +109,17 @@ export default function (Vue, Router) {
109
109
*
110
110
* @param {VueConstructor } App
111
111
* @param {String|Element } container
112
+ * @param {Function } [cb]
112
113
*/
113
114
114
- Router . prototype . start = function ( App , container ) {
115
+ Router . prototype . start = function ( App , container , cb ) {
115
116
/* istanbul ignore if */
116
117
if ( this . _started ) {
117
118
warn ( 'already started.' )
118
119
return
119
120
}
120
121
this . _started = true
122
+ this . _startCb = cb
121
123
if ( ! this . app ) {
122
124
/* istanbul ignore if */
123
125
if ( ! App || ! container ) {
Original file line number Diff line number Diff line change @@ -170,6 +170,10 @@ export default function (Vue, Router) {
170
170
startTransition ( )
171
171
}
172
172
173
+ if ( ! this . _rendered && this . _startCb ) {
174
+ this . _startCb . call ( null )
175
+ }
176
+
173
177
// HACK:
174
178
// set rendered to true after the transition start, so
175
179
// that components that are acitvated synchronously know
Original file line number Diff line number Diff line change @@ -20,7 +20,12 @@ describe('Core', function () {
20
20
var App = Vue . extend ( {
21
21
template : '<div><router-view></router-view></div>'
22
22
} )
23
- router . start ( App , el )
23
+ var cb = jasmine . createSpy ( )
24
+ router . start ( App , el , function ( ) {
25
+ expect ( router . app ) . toBeTruthy ( )
26
+ cb ( )
27
+ } )
28
+ expect ( cb ) . toHaveBeenCalled ( )
24
29
assertRoutes ( [
25
30
[ '/a' , 'AAA' ] ,
26
31
[ '/b' , 'BBB' ] ,
You can’t perform that action at this time.
0 commit comments