diff options
Diffstat (limited to 'src/elements/Dom.js')
-rw-r--r-- | src/elements/Dom.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/elements/Dom.js b/src/elements/Dom.js index 2fcedce..5d7dbac 100644 --- a/src/elements/Dom.js +++ b/src/elements/Dom.js @@ -4,6 +4,7 @@ import { eid, extend, makeInstance, + makeNode, register } from '../utils/adopter.js' import { find } from '../modules/core/selector' @@ -88,6 +89,10 @@ export default class Dom extends EventTarget { return this } + element (nodeName) { + return this.put(new Dom(makeNode(nodeName))) + } + // Get first child first () { return adopt(this.node.firstChild) @@ -285,12 +290,20 @@ export default class Dom extends EventTarget { fragment.appendChild(well.firstElementChild) } + let parent = this.parent() + // Add the whole fragment at once return outerHTML - ? this.replace(fragment) + ? this.replace(fragment) && parent : this.add(fragment) } + words (text) { + // This is faster than removing all children and adding a new one + this.node.textContent = text + return this + } + // write svgjs data to the dom writeDataToDom () { // dump variables recursively |