@@ -2,11 +2,12 @@ var React = require('react');
2
2
var warning = require ( 'react/lib/warning' ) ;
3
3
var copyProperties = require ( 'react/lib/copyProperties' ) ;
4
4
var Promise = require ( 'es6-promise' ) . Promise ;
5
+ var Route = require ( '../components/Route' ) ;
5
6
var goBack = require ( '../helpers/goBack' ) ;
6
7
var replaceWith = require ( '../helpers/replaceWith' ) ;
7
- var transitionTo = require ( '../helpers/transitionTo' ) ;
8
- var Route = require ( '../components/Route' ) ;
9
8
var Path = require ( '../helpers/Path' ) ;
9
+ var Redirect = require ( '../helpers/Redirect' ) ;
10
+ var Transition = require ( '../helpers/Transition' ) ;
10
11
var HashLocation = require ( '../locations/HashLocation' ) ;
11
12
var HistoryLocation = require ( '../locations/HistoryLocation' ) ;
12
13
var RefreshLocation = require ( '../locations/RefreshLocation' ) ;
@@ -49,15 +50,15 @@ var Routes = React.createClass({
49
50
} ,
50
51
51
52
/**
52
- * Handles cancelled transitions. By default, redirects replace the
53
- * current URL and aborts roll it back.
53
+ * Handles aborted transitions. By default, redirects replace the
54
+ * current URL and all others roll it back.
54
55
*/
55
- handleCancelledTransition : function ( transition , routes ) {
56
- var reason = transition . cancelReason ;
56
+ handleAbortedTransition : function ( transition , routes ) {
57
+ var reason = transition . abortReason ;
57
58
58
59
if ( reason instanceof Redirect ) {
59
60
replaceWith ( reason . to , reason . params , reason . query ) ;
60
- } else if ( reason instanceof Abort ) {
61
+ } else {
61
62
goBack ( ) ;
62
63
}
63
64
}
@@ -174,8 +175,8 @@ var Routes = React.createClass({
174
175
var routes = this ;
175
176
176
177
var promise = syncWithTransition ( routes , transition ) . then ( function ( newState ) {
177
- if ( transition . isCancelled ) {
178
- Routes . handleCancelledTransition ( transition , routes ) ;
178
+ if ( transition . isAborted ) {
179
+ Routes . handleAbortedTransition ( transition , routes ) ;
179
180
} else if ( newState ) {
180
181
ActiveStore . updateState ( newState ) ;
181
182
}
@@ -210,38 +211,6 @@ var Routes = React.createClass({
210
211
211
212
} ) ;
212
213
213
- function Transition ( path ) {
214
- this . path = path ;
215
- this . cancelReason = null ;
216
- this . isCancelled = false ;
217
- }
218
-
219
- copyProperties ( Transition . prototype , {
220
-
221
- abort : function ( ) {
222
- this . cancelReason = new Abort ( ) ;
223
- this . isCancelled = true ;
224
- } ,
225
-
226
- redirect : function ( to , params , query ) {
227
- this . cancelReason = new Redirect ( to , params , query ) ;
228
- this . isCancelled = true ;
229
- } ,
230
-
231
- retry : function ( ) {
232
- transitionTo ( this . path ) ;
233
- }
234
-
235
- } ) ;
236
-
237
- function Abort ( ) { }
238
-
239
- function Redirect ( to , params , query ) {
240
- this . to = to ;
241
- this . params = params ;
242
- this . query = query ;
243
- }
244
-
245
214
function findMatches ( path , route ) {
246
215
var matches = null ;
247
216
@@ -360,11 +329,11 @@ function syncWithTransition(routes, transition) {
360
329
}
361
330
362
331
return checkTransitionFromHooks ( fromMatches , transition ) . then ( function ( ) {
363
- if ( transition . isCancelled )
332
+ if ( transition . isAborted )
364
333
return ; // No need to continue.
365
334
366
335
return checkTransitionToHooks ( toMatches , transition ) . then ( function ( ) {
367
- if ( transition . isCancelled )
336
+ if ( transition . isAborted )
368
337
return ; // No need to continue.
369
338
370
339
var rootMatch = getRootMatch ( nextMatches ) ;
@@ -402,7 +371,7 @@ function checkTransitionFromHooks(matches, transition) {
402
371
promise = promise . then ( function ( ) {
403
372
var handler = match . route . props . handler ;
404
373
405
- if ( ! transition . isCancelled && handler . willTransitionFrom )
374
+ if ( ! transition . isAborted && handler . willTransitionFrom )
406
375
return handler . willTransitionFrom ( transition , match . component ) ;
407
376
} ) ;
408
377
} ) ;
@@ -422,7 +391,7 @@ function checkTransitionToHooks(matches, transition) {
422
391
promise = promise . then ( function ( ) {
423
392
var handler = match . route . props . handler ;
424
393
425
- if ( ! transition . isCancelled && handler . willTransitionTo )
394
+ if ( ! transition . isAborted && handler . willTransitionTo )
426
395
return handler . willTransitionTo ( transition , match . params ) ;
427
396
} ) ;
428
397
} ) ;
0 commit comments