diff options
Diffstat (limited to 'src/elements/Fragment.js')
-rw-r--r-- | src/elements/Fragment.js | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/elements/Fragment.js b/src/elements/Fragment.js index 228e93f..d2c4764 100644 --- a/src/elements/Fragment.js +++ b/src/elements/Fragment.js @@ -1,30 +1,31 @@ import Dom from './Dom.js' import { globals } from '../utils/window.js' -import { register } from '../utils/adopter.js' -import Svg from './Svg.js' +import { register, create } from '../utils/adopter.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 + // Import / Export raw xml + xml (xmlOrFn, outerXML, ns) { + if (typeof xmlOrFn === 'boolean') { + ns = outerXML + outerXML = xmlOrFn + xmlOrFn = null } - // act as getter if no svg string is given - if (svgOrFn == null || typeof svgOrFn === 'function') { - const wrapper = new Svg() + // because this is a fragment we have to put all elements into a wrapper first + // before we can get the innerXML from it + if (xmlOrFn == null || typeof xmlOrFn === 'function') { + const wrapper = new Dom(create('wrapper', ns)) wrapper.add(this.node.cloneNode(true)) - return wrapper.svg(svgOrFn, false) + return wrapper.xml(false, ns) } // Act as setter if we got a string - return super.svg(svgOrFn, false) + return super.xml(xmlOrFn, false, ns) } } |