aboutsummaryrefslogtreecommitdiffstats
path: root/src/elements/Fragment.js
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2020-04-08 07:32:38 +1000
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2020-04-08 07:32:38 +1000
commitd927f2d225d74fd3b3f41b298a19f6ba075702cf (patch)
treef53da1457a2a2df4685367a4184bf244fbd83378 /src/elements/Fragment.js
parent099bf6efad9c9971d805c8496a63314d91a71692 (diff)
downloadsvg.js-d927f2d225d74fd3b3f41b298a19f6ba075702cf.tar.gz
svg.js-d927f2d225d74fd3b3f41b298a19f6ba075702cf.zip
added Fragment, completed Dom Tests, fixed `matches()` for document fragments
Diffstat (limited to 'src/elements/Fragment.js')
-rw-r--r--src/elements/Fragment.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/elements/Fragment.js b/src/elements/Fragment.js
new file mode 100644
index 0000000..228e93f
--- /dev/null
+++ b/src/elements/Fragment.js
@@ -0,0 +1,34 @@
+import Dom from './Dom.js'
+import { globals } from '../utils/window.js'
+import { register } from '../utils/adopter.js'
+import Svg from './Svg.js'
+
+class Fragment extends Dom {
+ constructor (node = globals.document.createDocumentFragment()) {
+ super(node)
+ }
+
+ // Import / Export raw svg
+ svg (svgOrFn, outerHTML) {
+ if (svgOrFn === false) {
+ outerHTML = false
+ svgOrFn = null
+ }
+
+ // act as getter if no svg string is given
+ if (svgOrFn == null || typeof svgOrFn === 'function') {
+ const wrapper = new Svg()
+ wrapper.add(this.node.cloneNode(true))
+
+ return wrapper.svg(svgOrFn, false)
+ }
+
+ // Act as setter if we got a string
+ return super.svg(svgOrFn, false)
+ }
+
+}
+
+register(Fragment, 'Fragment')
+
+export default Fragment