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 //---- Internal support stuff
function objCopy(obj) { function objCopy(obj) {
if (obj === null) { if (obj == null) {
return null; return obj;
} else if (Array.isArray(obj)) { } else if (Array.isArray(obj)) {
return obj.slice(); return obj.slice();
} else { } else if (typeof obj === 'object') {
var copy = {}; var copy = {};
Object.keys(obj).forEach(function (k) { Object.keys(obj).forEach(function (k) {
copy[k] = obj[k]; copy[k] = obj[k];
}); });
return copy; return copy;
} else {
return obj;
} }
} }