Skip to content

Commit 24ad58c

Browse files
committed
[changed] Query changes aren't route changes
1 parent 265ca88 commit 24ad58c

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

modules/__tests__/transitionHooks-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ describe('When a router enters a branch', function () {
202202
history.pushState(null, '/news', { q: 1 })
203203
expect(newsFeedRouteEnterSpy.calls.length).toEqual(1)
204204
history.pushState(null, '/news', { q: 2 })
205-
expect(newsFeedRouteEnterSpy.calls.length).toEqual(2)
205+
expect(newsFeedRouteEnterSpy.calls.length).toEqual(1)
206206
done()
207207
})
208208
})

modules/computeChangedRoutes.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,11 @@ function routeParamsChanged(route, prevState, nextState) {
1111
})
1212
}
1313

14-
function routeQueryChanged(prevState, nextState) {
15-
return prevState.location.search !== nextState.location.search
16-
}
17-
1814
/**
1915
* Returns an object of { leaveRoutes, enterRoutes } determined by
2016
* the change from prevState to nextState. We leave routes if either
2117
* 1) they are not in the next state or 2) they are in the next state
22-
* but their params have changed (i.e. /users/123 => /users/456) or
23-
* 3) they are in the next state but the query has changed
24-
* (i.e. /search?query=foo => /search?query=bar)
18+
* but their params have changed (i.e. /users/123 => /users/456).
2519
*
2620
* leaveRoutes are ordered starting at the leaf route of the tree
2721
* we're leaving up to the common parent route. enterRoutes are ordered
@@ -34,9 +28,7 @@ function computeChangedRoutes(prevState, nextState) {
3428
let leaveRoutes, enterRoutes
3529
if (prevRoutes) {
3630
leaveRoutes = prevRoutes.filter(function (route) {
37-
return nextRoutes.indexOf(route) === -1
38-
|| routeParamsChanged(route, prevState, nextState)
39-
|| routeQueryChanged(prevState, nextState)
31+
return nextRoutes.indexOf(route) === -1 || routeParamsChanged(route, prevState, nextState)
4032
})
4133

4234
// onLeave hooks start at the leaf route.

0 commit comments

Comments
 (0)