Don't make objCopy crash on non-objects

This commit is contained in:
Connor Peet 2014-12-05 22:23:43 -05:00
parent b284480e5e
commit 1e793b182c

View file

@ -55,16 +55,18 @@ var isBrowser = function () {
//---- Internal support stuff
function objCopy(obj) {
if (obj === null) {
return null;
if (obj == null) {
return obj;
} else if (Array.isArray(obj)) {
return obj.slice();
} else {
} else if (typeof obj === 'object') {
var copy = {};
Object.keys(obj).forEach(function (k) {
copy[k] = obj[k];
});
return copy;
} else {
return obj;
}
}