Don't make objCopy crash on non-objects

master
Connor Peet 2014-12-05 22:23:43 -05:00
parent b284480e5e
commit 1e793b182c
1 changed files with 5 additions and 3 deletions

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;
}
}