Skip to content

Commit

Permalink
Merge pull request #2667 from exadel-inc/fix/connected-check
Browse files Browse the repository at this point in the history
fix(esl-base-element): fix subscription for component that currently out of DOM
  • Loading branch information
ala-n authored Sep 19, 2024
2 parents 2a721cf + 933990b commit 7f82312
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/modules/esl-base-element/core/esl-base-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export abstract class ESLBaseElement extends HTMLElement implements ESLBaseCompo
this._connected = true;
this.classList.add(this.baseTagName);

ESLEventUtils.subscribe(this);
// Automatic subscription happens only if the element is currently in the DOM
if (this.isConnected) ESLEventUtils.subscribe(this);
}
protected disconnectedCallback(): void {
this._connected = false;
Expand All @@ -58,7 +59,7 @@ export abstract class ESLBaseElement extends HTMLElement implements ESLBaseCompo
*/
protected attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {}

/** Check that the element is connected and `connectedCallback` has been executed */
/** Checks that the element's `connectedCallback` has been executed */
public get connected(): boolean {
return this._connected;
}
Expand Down

0 comments on commit 7f82312

Please sign in to comment.