Skip to content

Commit

Permalink
feat($state): make state data inheritance prototypical
Browse files Browse the repository at this point in the history
Modify state data inheritance to use prototypical inhertiance rather than Angular's extend method to enable more flexibility in handling state data.
  • Loading branch information
chrislambe committed Oct 2, 2015
1 parent 4da7e59 commit c4fec8c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
// inherit 'data' from parent and override by own values (if any)
data: function(state) {
if (state.parent && state.parent.data) {
state.data = state.self.data = extend({}, state.parent.data, state.data);
state.data = state.self.data = inherit(state.parent.data, state.data);
}
return state.data;
},
Expand Down
1 change: 1 addition & 0 deletions test/stateSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,7 @@ describe('state', function () {
expect($state.current.name).toEqual('HHH');
expect($state.current.data.propA).toEqual(HHH.data.propA);
expect($state.current.data.propB).toEqual(H.data.propB);
expect($state.current.data.hasOwnProperty('propB')).toBe(false);
expect($state.current.data.propB).toEqual(HH.data.propB);
expect($state.current.data.propC).toEqual(HHH.data.propC);
}));
Expand Down

0 comments on commit c4fec8c

Please sign in to comment.