From 9a5156db18300dc551c6f233cee0125ff91ede5a Mon Sep 17 00:00:00 2001 From: Radoslav Karaivanov Date: Mon, 9 Jan 2023 14:55:35 +0200 Subject: [PATCH] fix: Dangling references after element disconnect Several components did not call the parent `disconnectedCallback`, preventing triggering `hostDisconnected` for any controllers (theming in this case) and leading to a memory leak. --- src/components/checkbox/checkbox-base.ts | 1 + src/components/radio/radio.ts | 1 + src/components/select/select-group.ts | 1 + src/components/slider/slider-base.ts | 1 + 4 files changed, 4 insertions(+) diff --git a/src/components/checkbox/checkbox-base.ts b/src/components/checkbox/checkbox-base.ts index 17f89f524..d99f06985 100644 --- a/src/components/checkbox/checkbox-base.ts +++ b/src/components/checkbox/checkbox-base.ts @@ -141,6 +141,7 @@ export class IgcCheckboxBaseComponent extends EventEmitterMixin< public override disconnectedCallback() { this.removeEventListener('keyup', this.handleKeyUp); + super.disconnectedCallback(); } protected handleKeyUp() { diff --git a/src/components/radio/radio.ts b/src/components/radio/radio.ts index 0e91a5efe..7cebc1571 100644 --- a/src/components/radio/radio.ts +++ b/src/components/radio/radio.ts @@ -130,6 +130,7 @@ export default class IgcRadioComponent extends EventEmitterMixin< public override disconnectedCallback() { this.removeEventListener('keyup', this.handleKeyUp); + super.disconnectedCallback(); } protected handleKeyUp() { diff --git a/src/components/select/select-group.ts b/src/components/select/select-group.ts index e8e673fb6..e21761296 100644 --- a/src/components/select/select-group.ts +++ b/src/components/select/select-group.ts @@ -43,6 +43,7 @@ export default class IgcSelectGroupComponent extends IgcDropdownGroupComponent { public override disconnectedCallback() { this.observer.disconnect(); + super.disconnectedCallback(); } protected override getParent() { diff --git a/src/components/slider/slider-base.ts b/src/components/slider/slider-base.ts index 2b5236905..dfc41a313 100644 --- a/src/components/slider/slider-base.ts +++ b/src/components/slider/slider-base.ts @@ -267,6 +267,7 @@ export class IgcSliderBaseComponent extends LitElement { public override disconnectedCallback() { this.removeEventListener('keyup', this.handleKeyUp); + super.disconnectedCallback(); } protected handleKeyUp() {