Move style related actions to templates

This commit is contained in:
barsdeveloper
2021-12-10 21:05:44 +01:00
parent 7bc0f4e2f2
commit 6b02ab7e08
19 changed files with 2693 additions and 139 deletions

View File

@@ -1,25 +1,23 @@
/**
* @typedef {import(""../entity/Entity"").default} Entity
* @typedef {import("../graph/GraphElement").default} GraphElement
*/
export default class Template {
/**
* Computes the html content of the target element.
* @param {Entity} entity Entity representing the element
* @returns The computed html
* @param {GraphElement} entity Element of the graph
* @returns The result html
*/
render(entity) {
return ""
}
/**
* Returns the html elements rendered by this template.
* @param {Entity} entity Entity representing the element
* @returns The rendered elements
* Applies the style to the element.
* @param {GraphElement} element Element of the graph
*/
getElements(entity) {
let aDiv = document.createElement("div")
aDiv.innerHTML = this.render(entity)
return aDiv.childNodes
apply(element) {
// TODO replace with the safer element.setHTML(...) when it will be available
element.innerHTML = this.render(element)
}
}