@@ -82,9 +82,12 @@ export class History {
82
82
83
83
runQueue ( queue , iterator , ( ) => {
84
84
const postEnterCbs = [ ]
85
+ const enterGuards = extractEnterGuards ( activated , postEnterCbs , ( ) => {
86
+ return this . current === route
87
+ } )
85
88
// wait until async components are resolved before
86
89
// extracting in-component enter guards
87
- runQueue ( extractEnterGuards ( activated , postEnterCbs ) , iterator , ( ) => {
90
+ runQueue ( enterGuards , iterator , ( ) => {
88
91
if ( this . pending === route ) {
89
92
this . pending = null
90
93
cb ( route )
@@ -155,7 +158,11 @@ function extractLeaveGuards (matched: Array<RouteRecord>): Array<?Function> {
155
158
} ) . reverse ( )
156
159
}
157
160
158
- function extractEnterGuards ( matched : Array < RouteRecord > , cbs : Array < Function > ) : Array < ?Function > {
161
+ function extractEnterGuards (
162
+ matched : Array < RouteRecord > ,
163
+ cbs : Array < Function > ,
164
+ isValid : ( ) = > boolean
165
+ ) : Array < ?Function > {
159
166
return flatMapComponents ( matched , ( def , _ , match , key ) => {
160
167
const guard = def && def . beforeRouteEnter
161
168
if ( guard ) {
@@ -164,7 +171,12 @@ function extractEnterGuards (matched: Array<RouteRecord>, cbs: Array<Function>):
164
171
next ( cb )
165
172
if ( typeof cb === 'function' ) {
166
173
cbs . push ( ( ) => {
167
- cb ( match . instances [ key ] )
174
+ // #750
175
+ // if a router-view is wrapped with an out-in transition,
176
+ // the instance may not have been registered at this time.
177
+ // we will need to poll for registration until current route
178
+ // is no longer valid.
179
+ poll ( cb , match . instances , key , isValid )
168
180
} )
169
181
}
170
182
} )
@@ -173,6 +185,17 @@ function extractEnterGuards (matched: Array<RouteRecord>, cbs: Array<Function>):
173
185
} )
174
186
}
175
187
188
+ function poll ( cb , instances , key , isValid ) {
189
+ if ( instances [ key ] ) {
190
+ cb ( instances [ key ] )
191
+ } else if ( isValid ( ) ) {
192
+ setTimeout ( ( ) => {
193
+ console . log ( 'polling' )
194
+ poll ( cb , instances , key , isValid )
195
+ } , 16 )
196
+ }
197
+ }
198
+
176
199
function resolveAsyncComponents ( matched : Array < RouteRecord > ) : Array < ?Function > {
177
200
return flatMapComponents ( matched , ( def , _ , match , key ) => {
178
201
// if it's a function and doesn't have Vue options attached,
0 commit comments