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 {
5454
5555 // state
5656 this . _started = false
57+ this . _startCb = null
5758 this . _currentRoute = { }
5859 this . _currentTransition = null
5960 this . _previousTransition = null
Original file line number Diff line number Diff line change @@ -109,15 +109,17 @@ export default function (Vue, Router) {
109109 *
110110 * @param {VueConstructor } App
111111 * @param {String|Element } container
112+ * @param {Function } [cb]
112113 */
113114
114- Router . prototype . start = function ( App , container ) {
115+ Router . prototype . start = function ( App , container , cb ) {
115116 /* istanbul ignore if */
116117 if ( this . _started ) {
117118 warn ( 'already started.' )
118119 return
119120 }
120121 this . _started = true
122+ this . _startCb = cb
121123 if ( ! this . app ) {
122124 /* istanbul ignore if */
123125 if ( ! App || ! container ) {
Original file line number Diff line number Diff line change @@ -170,6 +170,10 @@ export default function (Vue, Router) {
170170 startTransition ( )
171171 }
172172
173+ if ( ! this . _rendered && this . _startCb ) {
174+ this . _startCb . call ( null )
175+ }
176+
173177 // HACK:
174178 // set rendered to true after the transition start, so
175179 // that components that are acitvated synchronously know
Original file line number Diff line number Diff line change @@ -20,7 +20,12 @@ describe('Core', function () {
2020 var App = Vue . extend ( {
2121 template : '<div><router-view></router-view></div>'
2222 } )
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 ( )
2429 assertRoutes ( [
2530 [ '/a' , 'AAA' ] ,
2631 [ '/b' , 'BBB' ] ,
You can’t perform that action at this time.
0 commit comments