mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:08:18 +08:00
36 lines
864 B
JavaScript
36 lines
864 B
JavaScript
export default class UEBlueprintDOMModel {
|
|
static dummyDiv = document.createElement('div')
|
|
|
|
static domTemplate(obj) {
|
|
return ``
|
|
}
|
|
|
|
constructor() {
|
|
this.domElement = null
|
|
}
|
|
|
|
createDOMElement() {
|
|
if (this.domElement) {
|
|
this.removeDOMElement()
|
|
}
|
|
this.constructor.dummyDiv.innerHTML = this.constructor.domTemplate(this)
|
|
this.domElement = this.constructor.dummyDiv.removeChild(this.constructor.dummyDiv.firstElementChild)
|
|
}
|
|
|
|
getDOMElement() {
|
|
if (!this.domElement) {
|
|
this.createDOMElement()
|
|
}
|
|
return this.domElement
|
|
}
|
|
|
|
removeDOMElement() {
|
|
if (!this.domElement) {
|
|
return false
|
|
}
|
|
this.domElement.parentElement.removeChild(this.domElement)
|
|
this.domElement = null
|
|
return true
|
|
}
|
|
}
|