Don't make objCopy crash on non-objects
This commit is contained in:
parent
b284480e5e
commit
1e793b182c
1 changed files with 5 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue