Skip to content

Commit eeb9c4e

Browse files
committed
Merge pull request angular-ui#1944 from ckniffen/bugfix/any-is-check
fix($state) The `is` check on type `any` will always return true.
2 parents da63b27 + ba6ed61 commit eeb9c4e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/urlMatcherFactory.js

-1
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,6 @@ function $UrlMatcherFactory() {
623623
any: { // does not encode/decode
624624
encode: angular.identity,
625625
decode: angular.identity,
626-
is: angular.identity,
627626
equals: angular.equals,
628627
pattern: /.*/
629628
}

test/stateSpec.js

+9
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ describe('state', function () {
2424
DD = { parent: D, params: { x: null, y: null, z: null } },
2525
DDDD = { parent: D, controller: function() {}, template: "hey"},
2626
E = { params: { i: {} } },
27+
F = { params: { a: '', b: false, c: 0, d: undefined, e: -1 }},
2728
H = { data: {propA: 'propA', propB: 'propB'} },
2829
HH = { parent: H },
2930
HHH = {parent: HH, data: {propA: 'overriddenA', propC: 'propC'} },
@@ -47,6 +48,7 @@ describe('state', function () {
4748
.state('DD', DD)
4849
.state('DDDD', DDDD)
4950
.state('E', E)
51+
.state('F', F)
5052
.state('H', H)
5153
.state('HH', HH)
5254
.state('HHH', HHH)
@@ -915,6 +917,7 @@ describe('state', function () {
915917
'DD',
916918
'DDDD',
917919
'E',
920+
'F',
918921
'H',
919922
'HH',
920923
'HHH',
@@ -982,6 +985,12 @@ describe('state', function () {
982985
expect($state.params).toEqual({ x: null, y: null });
983986
}));
984987

988+
it("should allow falsy default values for non-url params", inject(function($state, $q) {
989+
$state.go("F"); $q.flush();
990+
expect($state.current.name).toBe("F");
991+
expect($state.params).toEqual({ a: '', b: false, c: 0, d: undefined, e: -1 });
992+
}));
993+
985994
it("should allow arbitrary objects to pass for non-url params", inject(function($state, $q) {
986995
$state.go("D", { x: 100, y: { foo: 'bar' } }); $q.flush();
987996
expect($state.current.name).toBe("D");

0 commit comments

Comments
 (0)