diff options
-rw-r--r-- | src/elements/Dom.js | 11 | ||||
-rw-r--r-- | svg.js.d.ts | 4 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/elements/Dom.js b/src/elements/Dom.js index 7c36078..508bbc2 100644 --- a/src/elements/Dom.js +++ b/src/elements/Dom.js @@ -67,12 +67,17 @@ export default class Dom extends EventTarget { } // Clone element - clone (deep = true) { + clone (deep = true, assignNewIds = true) { // write dom data to the dom so the clone can pickup the data this.writeDataToDom() - // clone element and assign new id - return new this.constructor(assignNewId(this.node.cloneNode(deep))) + // clone element + var nodeClone = this.node.cloneNode(deep); + if (assignNewIds) { + // assign new id + nodeClone = assignNewId(nodeClone); + } + return new this.constructor(nodeClone) } // Iterates over all children and invokes a given block diff --git a/svg.js.d.ts b/svg.js.d.ts index c347d4d..6196e63 100644 --- a/svg.js.d.ts +++ b/svg.js.d.ts @@ -933,7 +933,7 @@ declare module "@svgdotjs/svg.js" { addTo(parent: Dom | HTMLElement | string): this
children(): List<Element>;
clear(): this;
- clone(): this;
+ clone(deep?: boolean, assignNewIds?: boolean): this;
each(block: (index: number, children: Element[]) => void, deep?: boolean): this;
element(element: string, inherit?: object): this;
first(): Element;
@@ -1180,7 +1180,7 @@ declare module "@svgdotjs/svg.js" { click(cb: Function | null): this;
clipper(): ClipPath;
clipWith(element: Element): this;
- clone(): this;
+ clone(deep?: boolean, assignNewIds?: boolean): this;
ctm(): Matrix;
cx(): number;
cx(x: number): this;
|