@@ -2,11 +2,12 @@ var React = require('react');
22var warning = require ( 'react/lib/warning' ) ;
33var copyProperties = require ( 'react/lib/copyProperties' ) ;
44var Promise = require ( 'es6-promise' ) . Promise ;
5+ var Route = require ( '../components/Route' ) ;
56var goBack = require ( '../helpers/goBack' ) ;
67var replaceWith = require ( '../helpers/replaceWith' ) ;
7- var transitionTo = require ( '../helpers/transitionTo' ) ;
8- var Route = require ( '../components/Route' ) ;
98var Path = require ( '../helpers/Path' ) ;
9+ var Redirect = require ( '../helpers/Redirect' ) ;
10+ var Transition = require ( '../helpers/Transition' ) ;
1011var HashLocation = require ( '../locations/HashLocation' ) ;
1112var HistoryLocation = require ( '../locations/HistoryLocation' ) ;
1213var RefreshLocation = require ( '../locations/RefreshLocation' ) ;
@@ -49,15 +50,15 @@ var Routes = React.createClass({
4950 } ,
5051
5152 /**
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.
5455 */
55- handleCancelledTransition : function ( transition , routes ) {
56- var reason = transition . cancelReason ;
56+ handleAbortedTransition : function ( transition , routes ) {
57+ var reason = transition . abortReason ;
5758
5859 if ( reason instanceof Redirect ) {
5960 replaceWith ( reason . to , reason . params , reason . query ) ;
60- } else if ( reason instanceof Abort ) {
61+ } else {
6162 goBack ( ) ;
6263 }
6364 }
@@ -174,8 +175,8 @@ var Routes = React.createClass({
174175 var routes = this ;
175176
176177 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 ) ;
179180 } else if ( newState ) {
180181 ActiveStore . updateState ( newState ) ;
181182 }
@@ -210,38 +211,6 @@ var Routes = React.createClass({
210211
211212} ) ;
212213
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-
245214function findMatches ( path , route ) {
246215 var matches = null ;
247216
@@ -360,11 +329,11 @@ function syncWithTransition(routes, transition) {
360329 }
361330
362331 return checkTransitionFromHooks ( fromMatches , transition ) . then ( function ( ) {
363- if ( transition . isCancelled )
332+ if ( transition . isAborted )
364333 return ; // No need to continue.
365334
366335 return checkTransitionToHooks ( toMatches , transition ) . then ( function ( ) {
367- if ( transition . isCancelled )
336+ if ( transition . isAborted )
368337 return ; // No need to continue.
369338
370339 var rootMatch = getRootMatch ( nextMatches ) ;
@@ -402,7 +371,7 @@ function checkTransitionFromHooks(matches, transition) {
402371 promise = promise . then ( function ( ) {
403372 var handler = match . route . props . handler ;
404373
405- if ( ! transition . isCancelled && handler . willTransitionFrom )
374+ if ( ! transition . isAborted && handler . willTransitionFrom )
406375 return handler . willTransitionFrom ( transition , match . component ) ;
407376 } ) ;
408377 } ) ;
@@ -422,7 +391,7 @@ function checkTransitionToHooks(matches, transition) {
422391 promise = promise . then ( function ( ) {
423392 var handler = match . route . props . handler ;
424393
425- if ( ! transition . isCancelled && handler . willTransitionTo )
394+ if ( ! transition . isAborted && handler . willTransitionTo )
426395 return handler . willTransitionTo ( transition , match . params ) ;
427396 } ) ;
428397 } ) ;
0 commit comments