From 7fd80aad24a577d330494bd4101eb76d461faad7 Mon Sep 17 00:00:00 2001 From: Deni Date: Wed, 21 Oct 2020 20:05:04 +0200 Subject: [PATCH] fix: IE11 clone() (#1029) * Fix clone() for IE11 Moving `_whitelist` and `_blacklist` initializations inside `proto` fixes: `createSetIterator called on incompatible receiver` error in IE11 * Clone _whitelist and _blacklist properly Improvement on previous commit * white space revert * Add missing key --- src/mixed.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mixed.js b/src/mixed.js index 64ad2e06f..8ee9e8946 100644 --- a/src/mixed.js +++ b/src/mixed.js @@ -98,8 +98,13 @@ const proto = (SchemaType.prototype = { // if the nested value is a schema we can skip cloning, since // they are already immutable - return cloneDeepWith(this, (value) => { + return cloneDeepWith(this, (value, key) => { if (isSchema(value) && value !== this) return value; + + // fix for ie11 when cloning Set and Map + if (key === '_whitelist' || key === '_blacklist') { + return value.clone(); + } }); },