Skip to content

Commit 62257a2

Browse files
committed
fix($state): registering ignores Object properties
Closes #511
1 parent 67d4f67 commit 62257a2

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/state.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $
161161

162162
var name = state.name;
163163
if (!isString(name) || name.indexOf('@') >= 0) throw new Error("State must have a valid name");
164-
if (states[name]) throw new Error("State '" + name + "'' is already defined");
164+
if (states.hasOwnProperty(name)) throw new Error("State '" + name + "'' is already defined");
165165

166166
// Get parent name
167167
var parentName =

test/stateSpec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ describe('state', function () {
8787
expect($state.current).toBe(state);
8888
}
8989

90+
describe('provider', function () {
91+
it ('should ignore Object properties when registering states', function () {
92+
expect(function() {
93+
stateProvider.state('toString', { url: "/to-string" });
94+
}).not.toThrow();
95+
expect(function() {
96+
stateProvider.state('watch', { url: "/watch" });
97+
}).not.toThrow();
98+
});
99+
});
100+
90101
describe('.transitionTo()', function () {
91102
it('returns a promise for the target state', inject(function ($state, $q) {
92103
var trans = $state.transitionTo(A, {});

0 commit comments

Comments
 (0)