d3-selection
Version:
Data-driven DOM manipulation: select elements and join them to data.
14 lines (11 loc) • 453 B
JavaScript
function selection_cloneShallow() {
var clone = this.cloneNode(false), parent = this.parentNode;
return parent ? parent.insertBefore(clone, this.nextSibling) : clone;
}
function selection_cloneDeep() {
var clone = this.cloneNode(true), parent = this.parentNode;
return parent ? parent.insertBefore(clone, this.nextSibling) : clone;
}
export default function(deep) {
return this.select(deep ? selection_cloneDeep : selection_cloneShallow);
}