Skip to content

Commit

Permalink
fix: prevent runaway event listeners by not rendering while disconnected
Browse files Browse the repository at this point in the history
  • Loading branch information
Westbrook Johnson authored and najikahalsema committed Aug 26, 2022
1 parent 2932392 commit aa8e8b2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/table/src/Table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,9 @@ export class Table extends SizedMixin(SpectrumElement, {
}

protected renderVirtualizedItems(index?: number): void {
// Rendering updates into the table while disconnected can
// cause runaway event binding in ancestor elements.
if (!this.isConnected) return;
if (!this.tableBody) {
this.tableBody = this.querySelector('sp-table-body') as TableBody;
if (!this.tableBody) {
Expand Down Expand Up @@ -478,4 +481,11 @@ export class Table extends SizedMixin(SpectrumElement, {
this.tableBody
);
}

public override disconnectedCallback(): void {
if (this.tableBody) {
render(html``, this.tableBody);
}
super.disconnectedCallback();
}
}

0 comments on commit aa8e8b2

Please sign in to comment.