Files
ueblueprint/js/element/ElementFactory.js
2023-04-15 15:29:21 +02:00

24 lines
642 B
JavaScript

/**
* @typedef {import("./IElement.js").default} IElement
* @typedef {new (...args) => IElement} ElementConstructor
*/
export default class ElementFactory {
/** @type {Map<String, ElementConstructor>} */
static #elementConstructors = new Map()
/**
* @param {String} tagName
* @param {ElementConstructor} entityConstructor
*/
static registerElement(tagName, entityConstructor) {
ElementFactory.#elementConstructors.set(tagName, entityConstructor)
}
/** @param {String} tagName */
static getConstructor(tagName) {
return ElementFactory.#elementConstructors.get(tagName)
}
}