Skip to content

Commit c4fec8c

Browse files
committed
feat($state): make state data inheritance prototypical
Modify state data inheritance to use prototypical inhertiance rather than Angular's extend method to enable more flexibility in handling state data.
1 parent 4da7e59 commit c4fec8c

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/state.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
4141
// inherit 'data' from parent and override by own values (if any)
4242
data: function(state) {
4343
if (state.parent && state.parent.data) {
44-
state.data = state.self.data = extend({}, state.parent.data, state.data);
44+
state.data = state.self.data = inherit(state.parent.data, state.data);
4545
}
4646
return state.data;
4747
},

test/stateSpec.js

+1
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,7 @@ describe('state', function () {
13381338
expect($state.current.name).toEqual('HHH');
13391339
expect($state.current.data.propA).toEqual(HHH.data.propA);
13401340
expect($state.current.data.propB).toEqual(H.data.propB);
1341+
expect($state.current.data.hasOwnProperty('propB')).toBe(false);
13411342
expect($state.current.data.propB).toEqual(HH.data.propB);
13421343
expect($state.current.data.propC).toEqual(HHH.data.propC);
13431344
}));

0 commit comments

Comments
 (0)