summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2020-03-29 10:47:16 +1000
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2020-03-29 10:47:16 +1000
commit28e74482b8cc7b7f2e4aca099ceea9f7d7a888d5 (patch)
treec69f495017fd96aaeee6dd39eb529c2c49e31bf3 /src
parentf8f63d4f976b7ed87d5c6fafcc4c32d9c6d9a270 (diff)
downloadsvg.js-28e74482b8cc7b7f2e4aca099ceea9f7d7a888d5.tar.gz
svg.js-28e74482b8cc7b7f2e4aca099ceea9f7d7a888d5.zip
fixed put and adopter, added tests to cover it
Diffstat (limited to 'src')
-rw-r--r--src/elements/Dom.js3
-rw-r--r--src/utils/adopter.js8
2 files changed, 7 insertions, 4 deletions
diff --git a/src/elements/Dom.js b/src/elements/Dom.js
index 6fd1b1b..2e081a8 100644
--- a/src/elements/Dom.js
+++ b/src/elements/Dom.js
@@ -162,6 +162,7 @@ export default class Dom extends EventTarget {
// Basically does the same as `add()` but returns the added element instead
put (element, i) {
+ element = makeInstance(element)
this.add(element, i)
return element
}
@@ -299,7 +300,7 @@ export default class Dom extends EventTarget {
const parent = this.parent()
if (!parent) {
- return node.put(this)
+ return this.addTo(node)
}
const position = parent.index(this)
diff --git a/src/utils/adopter.js b/src/utils/adopter.js
index 30eab84..b016837 100644
--- a/src/utils/adopter.js
+++ b/src/utils/adopter.js
@@ -29,13 +29,15 @@ export function makeInstance (element, isHTML = false) {
}
// Make sure, that HTML elements are created with the correct namespace
- var node = isHTML ? globals.document.createElement('div') : create('svg')
- node.innerHTML = element
+ var wrapper = isHTML ? globals.document.createElement('div') : create('svg')
+ wrapper.innerHTML = element
// We can use firstChild here because we know,
// that the first char is < and thus an element
- element = adopter(node.firstChild)
+ element = adopter(wrapper.firstChild)
+ // make sure, that element doesnt have its wrapper attached
+ wrapper.removeChild(wrapper.firstChild)
return element
}