Skip to content
This repository was archived by the owner on Jun 1, 2019. It is now read-only.

Commit 4ab72d1

Browse files
committed
Revert "Revert "Simplify arities of setPath/navigate(). Fixes STRML#81.""
This reverts commit 345c070.
1 parent 345c070 commit 4ab72d1

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

lib/RouterMixin.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,6 @@ var RouterMixin = {
137137
* @param {Callback} cb
138138
*/
139139
navigate: function(path, navigation, cb) {
140-
if (typeof navigation === 'function' && cb === undefined) {
141-
cb = navigation;
142-
navigation = {};
143-
}
144-
navigation = navigation || {};
145140
path = join(this.state.prefix, path);
146141
this.getEnvironment().setPath(path, navigation, cb);
147142
},

lib/environment/DummyEnvironment.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ DummyEnvironment.prototype.constructor = DummyEnvironment;
1717

1818
DummyEnvironment.prototype.getPath = emptyFunction.thatReturnsNull;
1919

20-
DummyEnvironment.prototype.setPath = function(path, cb) {
20+
DummyEnvironment.prototype.setPath = function(path, navigation, cb) {
21+
// Support old (path, cb) arity
22+
if (typeof navigation === 'function' && cb === undefined) {
23+
cb = navigation;
24+
navigation = {};
25+
}
2126
this.path = path;
2227
cb();
2328
};

lib/environment/Environment.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,18 @@ Environment.prototype.makeHref = function makeHref(path) {
4444
}
4545

4646
Environment.prototype.navigate = function navigate(path, navigation, cb) {
47+
return this.setPath(path, navigation, cb);
48+
}
49+
50+
Environment.prototype.setPath = function(path, navigation, cb) {
51+
// Support (path, cb) arity.
4752
if (typeof navigation === 'function' && cb === undefined) {
4853
cb = navigation;
4954
navigation = {};
5055
}
51-
return this.setPath(path, navigation, cb);
52-
}
56+
// Support (path) arity.
57+
if (!navigation) navigation = {};
5358

54-
Environment.prototype.setPath = function(path, navigation, cb) {
5559
if (!navigation.isPopState) {
5660
if (navigation.replace) {
5761
this.replaceState(path, navigation);

0 commit comments

Comments
 (0)