Skip to content

Commit

Permalink
transitionTo should return activeTransition when no-op
Browse files Browse the repository at this point in the history
Transitioning to a route that you're already
transitioning to should just return you that
currently active transition. 

Fixes root cause of emberjs/ember.js#10366
  • Loading branch information
machty committed Mar 26, 2015
1 parent 5081e7a commit ed45bc5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/router/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function getTransitionByIntent(intent, isIntermediate) {
}

// No-op. No need to create a new transition.
return new Transition(this);
return this.activeTransition || new Transition(this);
}

if (isIntermediate) {
Expand Down
9 changes: 9 additions & 0 deletions test/tests/router_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1628,6 +1628,15 @@ asyncTest("Error handling shouldn't trigger for transitions that are already abo
flushBackburner();
});

test("Transitions to the same destination as the active transition just return the active transition", function() {
expect(1);

var transition0 = router.handleURL('/index');
var transition1 = router.handleURL('/index');
equal(transition0, transition1);
flushBackburner();
});


test("can redirect from error handler", function() {

Expand Down

0 comments on commit ed45bc5

Please sign in to comment.