Skip to content

Commit bc6d25a

Browse files
authoredAug 5, 2024··
optional chain disconnects; fixes #2127 (#2129)
1 parent d0441f5 commit bc6d25a

File tree

8 files changed

+12
-9
lines changed

8 files changed

+12
-9
lines changed
 

Diff for: ‎docs/pages/resources/changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ Components with the <sl-badge variant="warning" pill>Experimental</sl-badge> bad
1212

1313
New versions of Shoelace are released as-needed and generally occur when a critical mass of changes have accumulated. At any time, you can see what's coming in the next release by visiting [next.shoelace.style](https://next.shoelace.style).
1414

15+
## Next
16+
17+
- Fixed a bug that caused errors to show in the console when components disconnect before before `firstUpdated()` executes [#2127]
18+
1519
## 2.16.0
1620

1721
- Added the Czech translation [#2084]

Diff for: ‎src/components/carousel/carousel.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default class SlCarousel extends ShoelaceElement {
103103

104104
disconnectedCallback(): void {
105105
super.disconnectedCallback();
106-
this.mutationObserver.disconnect();
106+
this.mutationObserver?.disconnect();
107107
}
108108

109109
protected firstUpdated(): void {

Diff for: ‎src/components/details/details.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export default class SlDetails extends ShoelaceElement {
8989

9090
disconnectedCallback() {
9191
super.disconnectedCallback();
92-
this.detailsObserver.disconnect();
92+
this.detailsObserver?.disconnect();
9393
}
9494

9595
private handleSummaryClick(event: MouseEvent) {

Diff for: ‎src/components/range/range.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export default class SlRange extends ShoelaceElement implements ShoelaceFormCont
132132

133133
disconnectedCallback() {
134134
super.disconnectedCallback();
135-
this.resizeObserver.unobserve(this.input);
135+
this.resizeObserver?.unobserve(this.input);
136136
}
137137

138138
private handleChange() {

Diff for: ‎src/components/split-panel/split-panel.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export default class SlSplitPanel extends ShoelaceElement {
8585

8686
disconnectedCallback() {
8787
super.disconnectedCallback();
88-
this.resizeObserver.unobserve(this);
88+
this.resizeObserver?.unobserve(this);
8989
}
9090

9191
private detectSize() {

Diff for: ‎src/components/tab-group/tab-group.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ export default class SlTabGroup extends ShoelaceElement {
120120

121121
disconnectedCallback() {
122122
super.disconnectedCallback();
123-
this.mutationObserver.disconnect();
124-
this.resizeObserver.unobserve(this.nav);
123+
this.mutationObserver?.disconnect();
124+
this.resizeObserver?.unobserve(this.nav);
125125
}
126126

127127
private getAllTabs() {

Diff for: ‎src/components/textarea/textarea.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export default class SlTextarea extends ShoelaceElement implements ShoelaceFormC
164164
disconnectedCallback() {
165165
super.disconnectedCallback();
166166
if (this.input) {
167-
this.resizeObserver.unobserve(this.input);
167+
this.resizeObserver?.unobserve(this.input);
168168
}
169169
}
170170

Diff for: ‎src/components/tree/tree.component.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ export default class SlTree extends ShoelaceElement {
111111

112112
disconnectedCallback() {
113113
super.disconnectedCallback();
114-
115-
this.mutationObserver.disconnect();
114+
this.mutationObserver?.disconnect();
116115
}
117116

118117
// Generates a clone of the expand icon element to use for each tree item

0 commit comments

Comments
 (0)
Please sign in to comment.