Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function clone(obj) {
if (typeof obj !== 'object' || obj === null) {
return obj;
}
if (clones.has(obj)) {
return clones.get(obj);
}
let objClone;
if (obj.constructor === JSAPI) {
objClone = new JSAPI({}, obj.parentNode);
clones.set(obj, objClone);
if (obj.parentNode) {
objClone.parentNode = clone(obj.parentNode);
}
cloneKeys(objClone, obj);
}
else if (
obj.constructor === CSSClassList ||
obj.constructor === CSSStyleDeclaration ||
obj.constructor === Object ||
obj.constructor === Array
) {
objClone = new obj.constructor();
clones.set(obj, objClone);
cloneKeys(objClone, obj);
function clone(obj) {
if (typeof obj !== 'object' || obj === null) {
return obj;
}
if (clones.has(obj)) {
return clones.get(obj);
}
let objClone;
if (obj.constructor === JSAPI) {
objClone = new JSAPI({}, obj.parentNode);
clones.set(obj, objClone);
if (obj.parentNode) {
objClone.parentNode = clone(obj.parentNode);
}
cloneKeys(objClone, obj);
}
else if (
obj.constructor === CSSClassList ||
obj.constructor === CSSStyleDeclaration ||
obj.constructor === Object ||
obj.constructor === Array
) {
objClone = new obj.constructor();
clones.set(obj, objClone);
cloneKeys(objClone, obj);