Skip to content

Commit

Permalink
fix(store): add the missing bracket in immutability meta-reducer (#1721)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-okrushko authored and brandonroberts committed Apr 10, 2019
1 parent 20a4d5e commit 56f8a59
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions modules/store/spec/meta-reducers/immutability_reducer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('immutabilityCheckMetaReducer:', () => {
immutabilityCheckMetaReducer((state, action) => {
reduce(action);
return state;
})({}, { type: 'invoke', numbers: [1, 2, 3] });
})({}, { type: 'invoke', numbers: [1, 2, 3], fun: function() {} });
}
});

Expand All @@ -48,7 +48,7 @@ describe('immutabilityCheckMetaReducer:', () => {
});

function invokeReducer(reduce: Function) {
immutabilityCheckMetaReducer((state, _action) => reduce(state))(
immutabilityCheckMetaReducer(state => reduce(state))(
{ numbers: [1, 2, 3] },
{ type: 'invoke' }
);
Expand Down
9 changes: 5 additions & 4 deletions modules/store/src/meta-reducers/immutability_reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ function freeze(target: any) {
Object.getOwnPropertyNames(target).forEach(prop => {
const propValue = target[prop];
if (
hasOwnProperty(target, prop) && targetIsFunction
hasOwnProperty(target, prop) &&
(targetIsFunction
? prop !== 'caller' && prop !== 'callee' && prop !== 'arguments'
: true &&
(isObjectLike(propValue) || isFunction(propValue)) &&
!Object.isFrozen(propValue)
: true) &&
(isObjectLike(propValue) || isFunction(propValue)) &&
!Object.isFrozen(propValue)
) {
freeze(propValue);
}
Expand Down

0 comments on commit 56f8a59

Please sign in to comment.