@@ -112,13 +112,15 @@ export class History {
112112 activated
113113 } = resolveQueue ( this . current . matched , route . matched )
114114
115+ const postCbs = [ ]
116+ const isValid = ( ) => this . current === route
115117 const queue : Array < ?NavigationGuard > = [ ] . concat (
116118 // in-component leave guards
117119 extractLeaveGuards ( deactivated ) ,
118120 // global before hooks
119121 this . router . beforeHooks ,
120122 // in-component update hooks
121- extractUpdateHooks ( updated ) ,
123+ extractUpdateHooks ( updated , postCbs , isValid ) ,
122124 // in-config enter guards
123125 activated . map ( m => m . beforeEnter ) ,
124126 // async components
@@ -161,11 +163,9 @@ export class History {
161163 }
162164
163165 runQueue ( queue , iterator , ( ) => {
164- const postEnterCbs = [ ]
165- const isValid = ( ) => this . current === route
166166 // wait until async components are resolved before
167167 // extracting in-component enter guards
168- const enterGuards = extractEnterGuards ( activated , postEnterCbs , isValid )
168+ const enterGuards = extractEnterGuards ( activated , postCbs , isValid )
169169 const queue = enterGuards . concat ( this . router . resolveHooks )
170170 runQueue ( queue , iterator , ( ) => {
171171 if ( this . pending !== route ) {
@@ -175,7 +175,7 @@ export class History {
175175 onComplete ( route )
176176 if ( this . router . app ) {
177177 this . router . app . $nextTick ( ( ) => {
178- postEnterCbs . forEach ( cb => { cb ( ) } )
178+ postCbs . forEach ( cb => { cb ( ) } )
179179 } )
180180 }
181181 } )
@@ -266,10 +266,6 @@ function extractLeaveGuards (deactivated: Array<RouteRecord>): Array<?Function>
266266 return extractGuards ( deactivated , 'beforeRouteLeave' , bindGuard , true )
267267}
268268
269- function extractUpdateHooks ( updated : Array < RouteRecord > ) : Array < ?Function > {
270- return extractGuards ( updated , 'beforeRouteUpdate' , bindGuard )
271- }
272-
273269function bindGuard ( guard : NavigationGuard , instance : ?_Vue ) : ?NavigationGuard {
274270 if ( instance ) {
275271 return function boundRouteGuard ( ) {
@@ -278,24 +274,34 @@ function bindGuard (guard: NavigationGuard, instance: ?_Vue): ?NavigationGuard {
278274 }
279275}
280276
277+ function extractUpdateHooks (
278+ updated : Array < RouteRecord > ,
279+ cbs : Array < Function > ,
280+ isValid : ( ) = > boolean
281+ ) : Array < ?Function > {
282+ return extractGuards ( updated , 'beforeRouteUpdate' , ( guard , instance , match , key ) => {
283+ return bindCbGuard ( bindGuard ( guard , instance ) , match , key , cbs , isValid )
284+ } )
285+ }
286+
281287function extractEnterGuards (
282288 activated : Array < RouteRecord > ,
283289 cbs : Array < Function > ,
284290 isValid : ( ) = > boolean
285291) : Array < ?Function > {
286292 return extractGuards ( activated , 'beforeRouteEnter' , ( guard , _ , match , key ) => {
287- return bindEnterGuard ( guard , match , key , cbs , isValid )
293+ return bindCbGuard ( guard , match , key , cbs , isValid )
288294 } )
289295}
290296
291- function bindEnterGuard (
297+ function bindCbGuard (
292298 guard : NavigationGuard ,
293299 match : RouteRecord ,
294300 key : string ,
295301 cbs : Array < Function > ,
296302 isValid : ( ) = > boolean
297303) : NavigationGuard {
298- return function routeEnterGuard ( to , from , next ) {
304+ return function ( to , from , next ) {
299305 return guard ( to , from , cb => {
300306 next ( cb )
301307 if ( typeof cb === 'function' ) {
0 commit comments