From 11c0864ba43bc797eb915f87d04ed86feda4e12f Mon Sep 17 00:00:00 2001 From: Jon Rimmer Date: Fri, 5 Jul 2019 20:37:49 +0100 Subject: [PATCH] fix(store): add immutability check for IE compatibility (#1997) IE errors when attempting to access the `caller` property of a function, so rearrange the freeze function to check for this first. Fixes #1991 --- .../src/meta-reducers/immutability_reducer.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/store/src/meta-reducers/immutability_reducer.ts b/modules/store/src/meta-reducers/immutability_reducer.ts index c157103ed8..ecec65ce9d 100644 --- a/modules/store/src/meta-reducers/immutability_reducer.ts +++ b/modules/store/src/meta-reducers/immutability_reducer.ts @@ -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); + } } });