Skip to content

Commit

Permalink
Pass the deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Serg046 committed Nov 14, 2024
1 parent a2bbd93 commit dee652b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/components/rating-box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export class RatingBox extends SlotComponent {
}

protected onInit = () => {
console.log(this.ratingService, this.createTableRow);
const header = this.createTableRow();
this.mainSlot.appendChild(header);
header.mainSlot.appendChild(this.createElement('div', 'Место'));
Expand Down
8 changes: 4 additions & 4 deletions src/composition-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import * as dicc from "./service-provider";
import { Component, ShadowMode } from "./components/component";

class ServiceProvider extends dicc.ServiceProvider {
addService<T>(id: string, factory: () => T) {
(this as any).importDefinitions({ [id]: { factory }});
addService<T>(id: string, deps: any[], factory: () => T) {
(this as any).importDefinitions({ [id]: { factory, deps }});
}

get(id: string) {
Expand All @@ -21,11 +21,11 @@ const serviceProvider = new ServiceProvider();
export function defineComponent<TComponent extends new (...args: any[]) => Component>(
name: string, ctor: TComponent, shadowMode: ShadowMode = ShadowMode.Attached) {
const id = `#${ctor.name}.0`;
const deps = serviceProvider.getDeps(id);
customElements.define(name, class extends ctor {
protected node: Node;

constructor(...args: any[]) {
const deps = serviceProvider.getDeps(id);
if (deps) {
super(...deps);
} else {
Expand All @@ -34,5 +34,5 @@ export function defineComponent<TComponent extends new (...args: any[]) => Compo
this.shadowMode = shadowMode;
}
});
serviceProvider.addService(id, () => document.createElement(name));
serviceProvider.addService(id, deps, () => document.createElement(name));
}
1 change: 1 addition & 0 deletions webpack.plugins.babel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export class DiccCompilerPlugin {

compile() {
const startTime = performance.now();

try {
execSync('npm run di');
}
Expand Down

0 comments on commit dee652b

Please sign in to comment.