@@ -62,27 +62,39 @@ export class History {
62
62
this . errorCbs . push ( errorCb )
63
63
}
64
64
65
- transitionTo ( location : RawLocation , onComplete ? : Function , onAbort ? : Function ) {
65
+ transitionTo (
66
+ location : RawLocation ,
67
+ onComplete ? : Function ,
68
+ onAbort ? : Function
69
+ ) {
66
70
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 ( )
71
77
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
+ }
84
96
}
85
- } )
97
+ )
86
98
}
87
99
88
100
confirmTransition ( route : Route , onComplete : Function , onAbort ? : Function ) {
@@ -113,11 +125,10 @@ export class History {
113
125
return abort ( new NavigationDuplicated ( route ) )
114
126
}
115
127
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
+ )
121
132
122
133
const queue : Array < ?NavigationGuard > = [ ] . concat (
123
134
// in-component leave guards
@@ -145,10 +156,8 @@ export class History {
145
156
abort ( to )
146
157
} else if (
147
158
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' ) )
152
161
) {
153
162
// next('/') or next({ path: '/' }) -> redirect
154
163
abort ( )
@@ -182,7 +191,9 @@ export class History {
182
191
onComplete ( route )
183
192
if ( this . router . app ) {
184
193
this . router . app . $nextTick ( ( ) => {
185
- postEnterCbs . forEach ( cb => { cb ( ) } )
194
+ postEnterCbs . forEach ( cb => {
195
+ cb ( )
196
+ } )
186
197
} )
187
198
}
188
199
} )
@@ -290,9 +301,13 @@ function extractEnterGuards (
290
301
cbs : Array < Function > ,
291
302
isValid : ( ) = > boolean
292
303
) : 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
+ )
296
311
}
297
312
298
313
function bindEnterGuard (
0 commit comments