mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-22 23:04:44 +08:00
Initial commit
This commit is contained in:
35
js/UEBlueprintDOMModel.js
Normal file
35
js/UEBlueprintDOMModel.js
Normal file
@@ -0,0 +1,35 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user