Skip to content

Commit

Permalink
Get rid of document.createElement
Browse files Browse the repository at this point in the history
  • Loading branch information
Serg046 committed Nov 15, 2024
1 parent da0af48 commit 815ec3b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/composition-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function defineComponent<TComponent extends new (...args: any[]) => Compo
name: string, ctor: TComponent, shadowMode: ShadowMode = ShadowMode.Attached) {
const id = `#${ctor.name}.0`;
const deps = serviceProvider.getDeps(id);
customElements.define(name, class extends ctor {
const webComponentCtor = class extends ctor {
protected node: Node;

constructor(...args: any[]) {
Expand All @@ -33,6 +33,7 @@ export function defineComponent<TComponent extends new (...args: any[]) => Compo
}
this.shadowMode = shadowMode;
}
});
serviceProvider.addService(id, deps, () => document.createElement(name));
};
customElements.define(name, webComponentCtor);
serviceProvider.addService(id, deps, () => new webComponentCtor());
}

0 comments on commit 815ec3b

Please sign in to comment.