Skip to content

Commit 773cf5c

Browse files
authored
Merge pull request #39 from jbpratt/remove-event-listener
fix: remove event listener on disconnect and unused vars
2 parents d1b97ac + 4625b96 commit 773cf5c

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

web/src/tab-summary.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { LitElement, html, css } from 'lit';
2-
import { map } from 'lit/directives/map.js';
32
// eslint-disable-next-line @typescript-eslint/no-unused-vars
43
import { customElement, property } from 'lit/decorators.js';
54
import { TabSummaryInfo } from './testgrid-dashboard-summary.js';

web/src/testgrid-dashboard-summary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function convertResponse(ts: TabSummary) {
8686
tsi.failuresSummary!.failureStats = failureStats
8787

8888
tsi.failuresSummary!.topFailingTests = [];
89-
ts.failuresSummary?.topFailingTests.forEach( (test, i) => {
89+
ts.failuresSummary?.topFailingTests.forEach( (test) => {
9090
const failingTest: FailingTestInfo = {
9191
displayName: test.displayName,
9292
failCount: test.failCount,

web/src/testgrid-data-content.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,30 @@ export class TestgridDataContent extends LitElement {
6969
navigateTab(this.dashboardName, this.tabName);
7070
}
7171

72+
private handleTabChanged = (evt: Event) => {
73+
this.tabName = (<CustomEvent>evt).detail.tabName;
74+
this.showTab = !this.showTab;
75+
this.highlightIndex(this.tabName);
76+
navigateTab(this.dashboardName, this.tabName!);
77+
};
78+
7279
/**
7380
* Lit-element lifecycle method.
7481
* Invoked when a component is added to the document's DOM.
7582
*/
7683
connectedCallback() {
7784
super.connectedCallback();
7885
this.fetchTabNames();
79-
window.addEventListener('tab-changed', (evt: Event) => {
80-
this.tabName = (<CustomEvent>evt).detail.tabName;
81-
this.showTab = !this.showTab;
82-
this.highlightIndex(this.tabName);
83-
navigateTab(this.dashboardName, this.tabName!);
84-
});
86+
window.addEventListener('tab-changed', this.handleTabChanged);
87+
}
88+
89+
/**
90+
* Lit-element lifecycle method.
91+
* Invoked when a component is removed from the document's DOM.
92+
*/
93+
disconnectedCallback() {
94+
super.disconnectedCallback();
95+
window.removeEventListener('tab-changed', this.handleTabChanged);
8596
}
8697

8798
/**

web/src/testgrid-grid-column-header.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { LitElement, html, css } from 'lit';
2-
import { styleMap } from 'lit/directives/style-map.js';
32
import { customElement, property } from 'lit/decorators.js';
43

54
@customElement('testgrid-grid-column-header')

web/test/testgrid-dashboard-summary.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ import {
55
unsafeStatic,
66
expect,
77
waitUntil,
8-
aTimeout,
98
} from '@open-wc/testing';
109

1110
import { TestgridDashboardSummary } from '../src/testgrid-dashboard-summary.js';
12-
import { TestgridFailuresSummary } from '../src/testgrid-failures-summary.js';
1311
import { TabSummary } from '../src/tab-summary.js';
1412

1513
describe('Testgrid Dashboard Summary page', () => {

0 commit comments

Comments
 (0)