Cloned object is === to base
kuraga opened this issue · comments
Alexander Kurakin commented
@sasaplus1 Good day!
How is it possible? Thanks.
'use strict';
var deepcopy = require('deepcopy');
var h = require('virtual-dom/h');
var base, copy;
base = h('span');
console.log(typeof base); // 'object'
console.log(Object.prototype.toString.call(base)); // '[object Object]'
copy = deepcopy(base);
console.log(base === copy); // true
sasaplus1 commented
'use strict';
var deepcopy = require('deepcopy'),
h = require('virtual-dom/h'),
VNode = require('virtual-dom/vnode/vnode'),
isVNode = require('virtual-dom/vnode/is-vnode');
var base = h('span');
var copy = deepcopy(base, function(target) {
if (isVNode(target)) {
return new VNode(
target.tagName,
target.properties,
target.children,
target.key,
target.namespace
);
}
});
console.log(copy === base);
console.log(copy);
Alexander Kurakin commented
support types are below:
* Object
console.log(typeof base); // 'object'
console.log(Object.prototype.toString.call(base)); // '[object Object]'
So is some nested property supported?
sasaplus1 commented
deepcopy
supported PlainObject. it can recursively copy. you can prototyping by Tonic.
deepcopy
can copy unknown classes as PlainObject, but it's unexpected results for yours.
Alexander Kurakin commented
@sasaplus1 thanks!