diff options
author | Philippe Bernard <philippe.bernard@gmail.com> | 2020-10-14 11:20:20 +0200 |
---|---|---|
committer | Philippe Bernard <philippe.bernard@gmail.com> | 2020-10-14 11:20:20 +0200 |
commit | c24eab6180fd86b2b5973d37d9a0099e1f50afbb (patch) | |
tree | 57fe74cb7a7849497e588c41831b29ffdca9aeb6 | |
parent | 99e176f76332b47a6c026dbd9dcf7742191b8b29 (diff) | |
download | svg.js-c24eab6180fd86b2b5973d37d9a0099e1f50afbb.tar.gz svg.js-c24eab6180fd86b2b5973d37d9a0099e1f50afbb.zip |
New paremeter assignNewIds for Dom.clone()
-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;
|