y-xml: hand over fake document if necessary

This commit is contained in:
Kevin Jahns 2017-11-07 21:06:29 -08:00
parent 5ed1818de5
commit c453593ee7
2 changed files with 7 additions and 5 deletions

View File

@ -110,10 +110,11 @@ export default class YXmlElement extends YXmlFragment {
}
return obj
}
getDom () {
getDom (_document) {
_document = _document || document
let dom = this._dom
if (dom == null) {
dom = document.createElement(this.nodeName)
dom = _document.createElement(this.nodeName)
this._dom = dom
dom._yxml = this
let attrs = this.getAttributes()
@ -121,7 +122,7 @@ export default class YXmlElement extends YXmlFragment {
dom.setAttribute(key, attrs[key])
}
this.forEach(yxml => {
dom.appendChild(yxml.getDom())
dom.appendChild(yxml.getDom(_document))
})
this._bindToDom(dom)
}

View File

@ -67,9 +67,10 @@ export default class YXmlText extends YText {
this._dom = dom
dom._yxml = this
}
getDom () {
getDom (_document) {
_document = _document || document
if (this._dom === null) {
const dom = document.createTextNode(this.toString())
const dom = _document.createTextNode(this.toString())
this._setDom(dom)
return dom
}