Skip to content

Commit

Permalink
[added] query argument to willTransitionTo
Browse files Browse the repository at this point in the history
  • Loading branch information
mjackson committed Aug 29, 2014
1 parent 4c26d1a commit 2a75f3e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions modules/components/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,17 +329,18 @@ function runTransitionHooks(routes, transition) {
toMatches = nextMatches;
}

var query = Path.extractQuery(transition.path) || {};

return runTransitionFromHooks(fromMatches, transition).then(function () {
if (transition.isAborted)
return; // No need to continue.

return runTransitionToHooks(toMatches, transition).then(function () {
return runTransitionToHooks(toMatches, transition, query).then(function () {
if (transition.isAborted)
return; // No need to continue.

var rootMatch = getRootMatch(nextMatches);
var params = (rootMatch && rootMatch.params) || {};
var query = Path.extractQuery(transition.path) || {};

return {
path: transition.path,
Expand Down Expand Up @@ -380,15 +381,15 @@ function runTransitionFromHooks(matches, transition) {
* with the transition object and any params that apply to that handler. Returns
* a promise that resolves after the last handler.
*/
function runTransitionToHooks(matches, transition) {
function runTransitionToHooks(matches, transition, query) {
var promise = Promise.resolve();

matches.forEach(function (match) {
promise = promise.then(function () {
var handler = match.route.props.handler;

if (!transition.isAborted && handler.willTransitionTo)
return handler.willTransitionTo(transition, match.params);
return handler.willTransitionTo(transition, match.params, query);
});
});

Expand Down

0 comments on commit 2a75f3e

Please sign in to comment.