Skip to content

Commit

Permalink
fix(jwc-core): component decorators doesn't return a function
Browse files Browse the repository at this point in the history
  • Loading branch information
wibus-wee committed Dec 16, 2022
1 parent 2e1e1f5 commit b827d9a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/jwc-core/src/decorators/component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { CustomElementProps } from "../types";

export function Component(_class: any, options: CustomElementProps) {
// set the default value for the isMounted option
if (options.isMounted === undefined) options.isMounted = true;
if (customElements.get(options.name)) {
console.warn(`The component ${options.name} already exists.`);
}
_class.$options = options; // add the options to the class
customElements.define(options.name, _class, options.options || {});
export function Component(options: CustomElementProps) {
return function (_class: any) {
// set the default value for the isMounted option
if (options.isMounted === undefined) options.isMounted = true;
if (customElements.get(options.name)) {
console.warn(`The component ${options.name} already exists.`);
}
_class.$options = options; // add the options to the class
customElements.define(options.name, _class, options.options || {});
};
}

0 comments on commit b827d9a

Please sign in to comment.