Skip to content
This repository was archived by the owner on May 26, 2023. It is now read-only.

Commit 6b576d9

Browse files
pearcemerrittchristopherthielen
authored andcommitted
fix(state): $state.is will wrongly return true as long as the last param matches even if the others are different. (#3530)
Closes #3300
1 parent b3950ea commit 6b576d9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/state.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
12661266

12671267
return !params || objectKeys(params).reduce(function(acc, key) {
12681268
var paramDef = state.params[key];
1269-
return acc && !paramDef || paramDef.type.equals($stateParams[key], params[key]);
1269+
return acc && (!paramDef || paramDef.type.equals($stateParams[key], params[key]));
12701270
}, true);
12711271
};
12721272

test/stateSpec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,13 @@ describe('state', function () {
817817
options.relative = $state.get('about.person.item');
818818
expect($state.is('^', undefined, options)).toBe(true);
819819
}));
820+
821+
it('should return false when the current state is passed with non matching parameters', inject(function ($state, $q) {
822+
$state.transitionTo(D, {x: 'foo', y: 'qux'});
823+
$q.flush();
824+
825+
expect($state.is(D, {x: 'bar', y: 'qux'})).toBe(false);
826+
}));
820827
});
821828

822829
describe('.includes()', function () {

0 commit comments

Comments
 (0)