Add custom HTML Elements for icons/SVG loading
This commit is contained in:
parent
0fcf24bfcb
commit
361ddfb7b6
7 changed files with 255 additions and 0 deletions
24
module/apps/elements/_index.mjs
Normal file
24
module/apps/elements/_index.mjs
Normal 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);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue