Fix error in component helper function

This commit is contained in:
Talia 2025-02-23 19:23:35 +01:00
parent 2e0d62b9d1
commit cc7fcaf1c9
Signed by: darkwiiplayer
GPG key ID: 7808674088232B3E

View file

@ -323,7 +323,8 @@ export const component = (name, generator, methods) => {
generator = name
name = camelToKebab(generator.name)
}
component[kebabToCamel(name)] = class extends HTMLElement{
const jsName = kebabToCamel(name)
component[jsName] = class extends HTMLElement{
/** @type {ObservableObject} */
state
@ -344,11 +345,12 @@ export const component = (name, generator, methods) => {
if (content) this.replaceChildren(content)
}
}
const element = component[jsName]
if (methods) {
Object.defineProperties(Element.prototype, Object.getOwnPropertyDescriptors(methods))
Object.defineProperties(element.prototype, Object.getOwnPropertyDescriptors(methods))
}
customElements.define(name, Element)
return Element;
customElements.define(name, element)
return element;
}
class Composition extends ObservableValue {