From 2a75f3ee9ea3f6eccd1c18e84747747bb72ebf38 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Fri, 29 Aug 2014 07:52:31 -0700 Subject: [PATCH] [added] query argument to willTransitionTo Fixes #246 --- modules/components/Routes.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/components/Routes.js b/modules/components/Routes.js index 8f12677772..5b0ae3142e 100644 --- a/modules/components/Routes.js +++ b/modules/components/Routes.js @@ -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, @@ -380,7 +381,7 @@ 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) { @@ -388,7 +389,7 @@ function runTransitionToHooks(matches, transition) { var handler = match.route.props.handler; if (!transition.isAborted && handler.willTransitionTo) - return handler.willTransitionTo(transition, match.params); + return handler.willTransitionTo(transition, match.params, query); }); });