[Bug] _$.clone does not deep clone
Explosion-Scratch opened this issue · 4 comments
Explosion-Scratch commented
We need this code instead:
export let clone = (item) => {
if (!item) { return item; }
var types = [ Number, String, Boolean ],
result;
types.forEach(function(type) {
if (item instanceof type) {
result = type( item );
}
});
if (typeof result == "undefined") {
if (Array.isArray(item)) {
result = [];
item.forEach(function(child, index, array) {
result[index] = clone( child );
});
} else if (typeof item == "object") {
if (item.nodeType && typeof item.cloneNode == "function") {
result = item.cloneNode( true );
} else if (!item.prototype) {
if (item instanceof Date) {
result = new Date(item);
} else {
result = {};
for (var i in item) {
result[i] = clone( item[i] );
}
}
} else {
if (false && item.constructor) {
result = new item.constructor();
} else {
result = item;
}
}
} else {
result = item;
}
}
return result;
}
GrahamSH-LLK commented
Can't you just commit? Lol
CubeyTheCube commented
Can't you just commit? Lol
if he commits then there will be no non-deep clone function!!!
Explosion-Scratch commented
Can't you just commit? Lol
My gitpod's broken =P
retronbv commented
Can't you just commit? Lol
My gitpod's broken =P
You dont need gitpod to commit