Skip to content

Commit

Permalink
Merge pull request #2279 from chrislambe/prototypical-data-inheritance
Browse files Browse the repository at this point in the history
feat($state): make state data inheritance prototypical
  • Loading branch information
nateabele committed Oct 2, 2015
2 parents 4da7e59 + c4fec8c commit 6f723a5
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 6f723a5

Please sign in to comment.