Skip to content

Commit 0807247

Browse files
chrislambechristopherthielen
authored andcommitted
cherry-pick c4fec8c from 0.2.17
1 parent 016ff92 commit 0807247

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/state/stateBuilder.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @module state */ /** for typedoc */
2-
import {map, noop, extend, pick, omit, values, applyPairs, forEach} from "../common/common";
2+
import {map, noop, extend, inherit, pick, omit, values, applyPairs, forEach} from "../common/common";
33
import {isDefined, isFunction, isString} from "../common/predicates";
44
import {prop} from "../common/hof";
55
import {StateDeclaration} from "./interface";
@@ -60,7 +60,7 @@ export class StateBuilder {
6060

6161
data: [function (state: State) {
6262
if (state.parent && state.parent.data) {
63-
state.data = state.self.data = extend({}, state.parent.data, state.data);
63+
state.data = state.self.data = inherit(state.parent.data, state.data);
6464
}
6565
return state.data;
6666
}],

test/stateSpec.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ describe('state helpers', function() {
125125

126126
it('should inherit parent data', function() {
127127
var state = angular.extend(states['home.withData.child'], { self: {} });
128-
expect(builder.builder('data')(state)).toEqual({ val1: "foo", val2: "baz" });
128+
expect(builder.builder('data')(state)).toEqualData({ val1: "foo", val2: "baz" });
129129

130-
var state = angular.extend(states['home.withData'], { self: {} });
131-
expect(builder.builder('data')(state)).toEqual({ val1: "foo", val2: "bar" });
130+
state = angular.extend(states['home.withData'], { self: {} });
131+
expect(builder.builder('data')(state)).toEqualData({ val1: "foo", val2: "bar" });
132132
});
133133

134134
it('should compile a UrlMatcher for ^ URLs', function() {
@@ -1478,6 +1478,7 @@ describe('state', function () {
14781478
expect($state.current.name).toEqual('HHH');
14791479
expect($state.current.data.propA).toEqual(HHH.data.propA);
14801480
expect($state.current.data.propB).toEqual(H.data.propB);
1481+
expect($state.current.data.hasOwnProperty('propB')).toBe(false);
14811482
expect($state.current.data.propB).toEqual(HH.data.propB);
14821483
expect($state.current.data.propC).toEqual(HHH.data.propC);
14831484
}));

0 commit comments

Comments
 (0)