Add custom HTML Elements for icons/SVG loading

This commit is contained in:
Oliver-Akins 2025-07-13 21:49:01 -06:00
parent 0fcf24bfcb
commit 361ddfb7b6
7 changed files with 255 additions and 0 deletions

View file

@ -0,0 +1,24 @@
import { Logger } from "../../utils/Logger.mjs";
import { TafIcon } from "./Icon.mjs";
import { TafSVGLoader } from "./svgLoader.mjs";
const components = [
TafSVGLoader,
TafIcon,
];
export function registerCustomComponents() {
(CONFIG.CACHE ??= {}).componentListeners ??= [];
for (const component of components) {
if (!window.customElements.get(component.elementName)) {
Logger.debug(`Registering component "${component.elementName}"`);
window.customElements.define(
component.elementName,
component,
);
if (component.formAssociated) {
CONFIG.CACHE.componentListeners.push(component.elementName);
}
};
}
};