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
|
//---- 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue