From c4fec8c7998113902af4152d716c42dada6eb465 Mon Sep 17 00:00:00 2001 From: Chris Lambe Date: Fri, 2 Oct 2015 10:38:12 -0500 Subject: [PATCH] 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. --- src/state.js | 2 +- test/stateSpec.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/state.js b/src/state.js index 7076cc0ab..be36c99bc 100644 --- a/src/state.js +++ b/src/state.js @@ -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; }, diff --git a/test/stateSpec.js b/test/stateSpec.js index a8f45ac4a..7249895bf 100644 --- a/test/stateSpec.js +++ b/test/stateSpec.js @@ -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); }));