@@ -62,27 +62,39 @@ export class History {
6262 this . errorCbs . push ( errorCb )
6363 }
6464
65- transitionTo ( location : RawLocation , onComplete ? : Function , onAbort ? : Function ) {
65+ transitionTo (
66+ location : RawLocation ,
67+ onComplete ? : Function ,
68+ onAbort ? : Function
69+ ) {
6670 const route = this . router . match ( location , this . current )
67- this . confirmTransition ( route , ( ) => {
68- this . updateRoute ( route )
69- onComplete && onComplete ( route )
70- this . ensureURL ( )
71+ this . confirmTransition (
72+ route ,
73+ ( ) => {
74+ this . updateRoute ( route )
75+ onComplete && onComplete ( route )
76+ this . ensureURL ( )
7177
72- // fire ready cbs once
73- if ( ! this . ready ) {
74- this . ready = true
75- this . readyCbs . forEach ( cb => { cb ( route ) } )
76- }
77- } , err => {
78- if ( onAbort ) {
79- onAbort ( err )
80- }
81- if ( err && ! this . ready ) {
82- this . ready = true
83- this . readyErrorCbs . forEach ( cb => { cb ( err ) } )
78+ // fire ready cbs once
79+ if ( ! this . ready ) {
80+ this . ready = true
81+ this . readyCbs . forEach ( cb => {
82+ cb ( route )
83+ } )
84+ }
85+ } ,
86+ err => {
87+ if ( onAbort ) {
88+ onAbort ( err )
89+ }
90+ if ( err && ! this . ready ) {
91+ this . ready = true
92+ this . readyErrorCbs . forEach ( cb => {
93+ cb ( err )
94+ } )
95+ }
8496 }
85- } )
97+ )
8698 }
8799
88100 confirmTransition ( route : Route , onComplete : Function , onAbort ? : Function ) {
@@ -113,11 +125,10 @@ export class History {
113125 return abort ( new NavigationDuplicated ( route ) )
114126 }
115127
116- const {
117- updated,
118- deactivated,
119- activated
120- } = resolveQueue ( this . current . matched , route . matched )
128+ const { updated, deactivated, activated } = resolveQueue (
129+ this . current . matched ,
130+ route . matched
131+ )
121132
122133 const queue : Array < ?NavigationGuard > = [ ] . concat (
123134 // in-component leave guards
@@ -145,10 +156,8 @@ export class History {
145156 abort ( to )
146157 } else if (
147158 typeof to === 'string' ||
148- ( typeof to === 'object' && (
149- typeof to . path === 'string' ||
150- typeof to . name === 'string'
151- ) )
159+ ( typeof to === 'object' &&
160+ ( typeof to . path === 'string' || typeof to . name === 'string' ) )
152161 ) {
153162 // next('/') or next({ path: '/' }) -> redirect
154163 abort ( )
@@ -182,7 +191,9 @@ export class History {
182191 onComplete ( route )
183192 if ( this . router . app ) {
184193 this . router . app . $nextTick ( ( ) => {
185- postEnterCbs . forEach ( cb => { cb ( ) } )
194+ postEnterCbs . forEach ( cb => {
195+ cb ( )
196+ } )
186197 } )
187198 }
188199 } )
@@ -290,9 +301,13 @@ function extractEnterGuards (
290301 cbs : Array < Function > ,
291302 isValid : ( ) = > boolean
292303) : Array < ?Function > {
293- return extractGuards ( activated , 'beforeRouteEnter' , ( guard , _ , match , key ) => {
294- return bindEnterGuard ( guard , match , key , cbs , isValid )
295- } )
304+ return extractGuards (
305+ activated ,
306+ 'beforeRouteEnter' ,
307+ ( guard , _ , match , key ) = > {
308+ return bindEnterGuard ( guard , match , key , cbs , isValid )
309+ }
310+ )
296311}
297312
298313function bindEnterGuard (
0 commit comments