Skip to content

Commit

Permalink
fix(store): add immutability check for IE compatibility (#1997)
Browse files Browse the repository at this point in the history
IE errors when attempting to access the `caller` property of a function,
so rearrange the freeze function to check for this first.

Fixes #1991
  • Loading branch information
jonrimmer authored and brandonroberts committed Jul 5, 2019
1 parent 2b8178d commit 11c0864
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions modules/store/src/meta-reducers/immutability_reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@ function freeze(target: any) {
const targetIsFunction = isFunction(target);

Object.getOwnPropertyNames(target).forEach(prop => {
const propValue = target[prop];
if (
hasOwnProperty(target, prop) &&
(targetIsFunction
? prop !== 'caller' && prop !== 'callee' && prop !== 'arguments'
: true) &&
(isObjectLike(propValue) || isFunction(propValue)) &&
!Object.isFrozen(propValue)
: true)
) {
freeze(propValue);
const propValue = target[prop];

if (
(isObjectLike(propValue) || isFunction(propValue)) &&
!Object.isFrozen(propValue)
) {
freeze(propValue);
}
}
});

Expand Down

0 comments on commit 11c0864

Please sign in to comment.