From f988f5c75ba87be955f5c0fbbe77f0bd9e6b54d7 Mon Sep 17 00:00:00 2001 From: Taye Adeyemi Date: Tue, 2 Jan 2018 17:25:35 +0000 Subject: [PATCH] *: only clone plain objects Close #570 --- src/Interactable.js | 2 +- src/utils/clone.js | 2 +- src/utils/is.js | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Interactable.js b/src/Interactable.js index c48593b11..7f6d2d6b9 100644 --- a/src/Interactable.js +++ b/src/Interactable.js @@ -59,7 +59,7 @@ class Interactable { actionOptions[optionName] = arr.from(optionValue); } // if the option value is an object - else if (!isArray && is.object(optionValue)) { + else if (!isArray && is.plainObject(optionValue)) { // copy the object actionOptions[optionName] = extend( actionOptions[optionName] || {}, diff --git a/src/utils/clone.js b/src/utils/clone.js index 4a4c80122..ce77da54d 100644 --- a/src/utils/clone.js +++ b/src/utils/clone.js @@ -3,7 +3,7 @@ const is = require('./is'); module.exports = function clone (source) { const dest = {}; for (const prop in source) { - if (is.object(source[prop])) { + if (is.plainObject(source[prop])) { dest[prop] = clone(source[prop]); } else { dest[prop] = source[prop]; diff --git a/src/utils/is.js b/src/utils/is.js index a6f02ae34..c4ebbb878 100644 --- a/src/utils/is.js +++ b/src/utils/is.js @@ -27,6 +27,8 @@ const is = { ? thing instanceof _window.Element //DOM2 : thing.nodeType === 1 && typeof thing.nodeName === 'string'); }, + + plainObject: thing => is.object(thing) && thing.constructor.name === 'Object', }; is.array = thing => (is.object(thing)