diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2020-09-27 13:35:47 +1000 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2020-09-27 13:35:47 +1000 |
commit | 99e176f76332b47a6c026dbd9dcf7742191b8b29 (patch) | |
tree | 18fe3fbadb6fde0ca05b75ae09d7510de0a17ed0 /src | |
parent | 3f78cb81973f9c6c9a0754a555c939e81d24a1ff (diff) | |
download | svg.js-99e176f76332b47a6c026dbd9dcf7742191b8b29.tar.gz svg.js-99e176f76332b47a6c026dbd9dcf7742191b8b29.zip |
fix `clone()` to return the correct instance (#1154)
Diffstat (limited to 'src')
-rw-r--r-- | src/elements/Dom.js | 2 | ||||
-rw-r--r-- | src/utils/adopter.js | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/elements/Dom.js b/src/elements/Dom.js index eb59418..7c36078 100644 --- a/src/elements/Dom.js +++ b/src/elements/Dom.js @@ -72,7 +72,7 @@ export default class Dom extends EventTarget { this.writeDataToDom() // clone element and assign new id - return assignNewId(this.node.cloneNode(deep)) + return new this.constructor(assignNewId(this.node.cloneNode(deep))) } // Iterates over all children and invokes a given block diff --git a/src/utils/adopter.js b/src/utils/adopter.js index 2de1b27..a440e4c 100644 --- a/src/utils/adopter.js +++ b/src/utils/adopter.js @@ -107,10 +107,11 @@ export function assignNewId (node) { } if (node.id) { - return adopt(node).id(eid(node.nodeName)) + node.id = eid(node.nodeName) + return node } - return adopt(node) + return node } // Method for extending objects |