Skip to content

Commit

Permalink
EVEN MORE CLEANUP
Browse files Browse the repository at this point in the history
  • Loading branch information
deebloo committed Jan 29, 2025
1 parent 42e7590 commit 71e46c6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/di/src/lib/injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ export class Injector {
const instance = this.#instances.get(token);

const metadata = readMetadata<T>(token);
const injector = readInjector(instance);
const injector = readInjector(instance) ?? this;

if (metadata) {
callLifecycle(instance, injector ?? this, metadata.onInjected);
callLifecycle(instance, injector, metadata.onInjected);
}

return instance;
Expand Down Expand Up @@ -108,7 +108,7 @@ export class Injector {
* Only values that are objects are able to have associated injectors
*/
if (typeof instance === "object" && instance !== null) {
const injector = readInjector(instance);
const injector = readInjector(instance) ?? this;

if (injector && injector !== this) {
/**
Expand All @@ -128,8 +128,8 @@ export class Injector {
const metadata = readMetadata<T>(token);

if (metadata) {
callLifecycle(instance, injector ?? this, metadata.onCreated);
callLifecycle(instance, injector ?? this, metadata.onInjected);
callLifecycle(instance, injector, metadata.onCreated);
callLifecycle(instance, injector, metadata.onInjected);
}
}

Expand Down

0 comments on commit 71e46c6

Please sign in to comment.