y-xml: hand over fake document if necessary
This commit is contained in:
		
							parent
							
								
									5ed1818de5
								
							
						
					
					
						commit
						c453593ee7
					
				@ -110,10 +110,11 @@ export default class YXmlElement extends YXmlFragment {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    return obj
 | 
					    return obj
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  getDom () {
 | 
					  getDom (_document) {
 | 
				
			||||||
 | 
					    _document = _document || document
 | 
				
			||||||
    let dom = this._dom
 | 
					    let dom = this._dom
 | 
				
			||||||
    if (dom == null) {
 | 
					    if (dom == null) {
 | 
				
			||||||
      dom = document.createElement(this.nodeName)
 | 
					      dom = _document.createElement(this.nodeName)
 | 
				
			||||||
      this._dom = dom
 | 
					      this._dom = dom
 | 
				
			||||||
      dom._yxml = this
 | 
					      dom._yxml = this
 | 
				
			||||||
      let attrs = this.getAttributes()
 | 
					      let attrs = this.getAttributes()
 | 
				
			||||||
@ -121,7 +122,7 @@ export default class YXmlElement extends YXmlFragment {
 | 
				
			|||||||
        dom.setAttribute(key, attrs[key])
 | 
					        dom.setAttribute(key, attrs[key])
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      this.forEach(yxml => {
 | 
					      this.forEach(yxml => {
 | 
				
			||||||
        dom.appendChild(yxml.getDom())
 | 
					        dom.appendChild(yxml.getDom(_document))
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
      this._bindToDom(dom)
 | 
					      this._bindToDom(dom)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -67,9 +67,10 @@ export default class YXmlText extends YText {
 | 
				
			|||||||
    this._dom = dom
 | 
					    this._dom = dom
 | 
				
			||||||
    dom._yxml = this
 | 
					    dom._yxml = this
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  getDom () {
 | 
					  getDom (_document) {
 | 
				
			||||||
 | 
					    _document = _document || document
 | 
				
			||||||
    if (this._dom === null) {
 | 
					    if (this._dom === null) {
 | 
				
			||||||
      const dom = document.createTextNode(this.toString())
 | 
					      const dom = _document.createTextNode(this.toString())
 | 
				
			||||||
      this._setDom(dom)
 | 
					      this._setDom(dom)
 | 
				
			||||||
      return dom
 | 
					      return dom
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user