Skip to content

Commit

Permalink
*: only clone plain objects
Browse files Browse the repository at this point in the history
Close #570
  • Loading branch information
taye committed Jan 2, 2018
1 parent b4839f0 commit 954a408
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 2 additions & 0 deletions src/utils/is.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 954a408

Please sign in to comment.