From 0e9548f415528c21d161e3c47f778300e3629f0e Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Sat, 23 Mar 2019 20:11:38 +0100 Subject: [PATCH] fix: detect polyfilled Map & Set objects, closes #744 --- src/util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util.js b/src/util.js index fe16fae5a0..9f33ac5f86 100644 --- a/src/util.js +++ b/src/util.js @@ -131,9 +131,9 @@ function replacer (key) { } else if (type === 'symbol') { return `[native Symbol ${Symbol.prototype.toString.call(val)}]` } else if (val !== null && type === 'object') { - if (val instanceof Map) { + if (val instanceof Map || val.toString() === '[object Map]') { return encodeCache.cache(val, () => getCustomMapDetails(val)) - } else if (val instanceof Set) { + } else if (val instanceof Set || val.toString() === '[object Set]') { return encodeCache.cache(val, () => getCustomSetDetails(val)) } else if (val instanceof RegExp) { // special handling of native type