Compare commits

..

3 commits
v0.0.0 ... main

Author SHA1 Message Date
474f6edea7 update 2025-01-13 18:56:28 +01:00
9cc97a4214 fix link to dom in components 2025-01-13 18:55:47 +01:00
809a0b8014 fix empty template error 2025-01-13 15:14:07 +01:00
3 changed files with 6 additions and 3 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@lightweight-sdk/web-component",
"version": "0.0.0",
"version": "0.0.2",
"description": "A lightweight library to build web components easily",
"scripts": {
"build": "tsc -b",

View file

@ -58,11 +58,13 @@ export function CustomComponent<T extends ConstructorFunction<AbstractComponent>
}
// Apply any specified CSS classes to the component root element
if (p.cssClasses) {
this.classList.add(...p.cssClasses);
}
// Process and link properties specified in __linkedProperties to their DOM elements
for (const requested of this.__linkedProperties ?? []) {
const elt = findRefElement(requested.ref);
const elt = findRefElement(requested.ref, this);
if (elt == null) {
throw new Error(`ref ${requested.ref} not found`);
}

View file

@ -21,5 +21,6 @@ export function findRefElement(ref: string, parent?: HTMLElement): HTMLElement |
* @returns the template as a string
*/
export function parseModuleToHtml(mod: any): string {
if (mod == null) return "";
return "default" in mod ? mod.default as string : "";
}