mirror of
https://github.com/shoelace-style/shoelace.git
synced 2026-01-12 11:09:13 +00:00
Use disconnectedCallback instead of componentDidUnload; fixes #161
This commit is contained in:
@@ -34,8 +34,9 @@ export class Card {
|
||||
this.host.shadowRoot.addEventListener('slotchange', this.updateSlots);
|
||||
}
|
||||
|
||||
componentDidUnload() {
|
||||
disconnectedCallback() {
|
||||
this.host.shadowRoot.removeEventListener('slotchange', this.updateSlots);
|
||||
console.log('cleanup');
|
||||
}
|
||||
|
||||
updateSlots() {
|
||||
|
||||
@@ -69,7 +69,7 @@ export class Details {
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUnload() {
|
||||
disconnectedCallback() {
|
||||
focusVisible.unobserve(this.details);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ export class Dialog {
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUnload() {
|
||||
disconnectedCallback() {
|
||||
unlockBodyScrolling(this.host);
|
||||
|
||||
this.host.shadowRoot.removeEventListener('slotchange', this.updateSlots);
|
||||
|
||||
@@ -98,7 +98,7 @@ export class Drawer {
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUnload() {
|
||||
disconnectedCallback() {
|
||||
unlockBodyScrolling(this.host);
|
||||
|
||||
this.host.shadowRoot.removeEventListener('slotchange', this.updateSlots);
|
||||
|
||||
@@ -118,7 +118,7 @@ export class Dropdown {
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUnload() {
|
||||
disconnectedCallback() {
|
||||
this.hide();
|
||||
this.popover.destroy();
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ export class IconButton {
|
||||
focusVisible.observe(this.button);
|
||||
}
|
||||
|
||||
componentDidUnload() {
|
||||
disconnectedCallback() {
|
||||
focusVisible.unobserve(this.button);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ export class Rating {
|
||||
focusVisible.observe(this.rating);
|
||||
}
|
||||
|
||||
componentDidUnload() {
|
||||
disconnectedCallback() {
|
||||
focusVisible.unobserve(this.rating);
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ export class Select {
|
||||
requestAnimationFrame(() => this.syncItemsFromValue());
|
||||
}
|
||||
|
||||
componentDidUnload() {
|
||||
disconnectedCallback() {
|
||||
this.menu.querySelector('slot').removeEventListener('slotchange', this.handleSlotChange);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ export class TabGroup {
|
||||
this.mutationObserver.observe(this.host, { attributes: true, childList: true, subtree: true });
|
||||
}
|
||||
|
||||
componentDidUnload() {
|
||||
disconnectedCallback() {
|
||||
this.mutationObserver.disconnect();
|
||||
focusVisible.unobserve(this.tabGroup);
|
||||
this.resizeObserver.unobserve(this.nav);
|
||||
|
||||
@@ -114,7 +114,7 @@ export class Textarea {
|
||||
this.resizeObserver.observe(this.textarea);
|
||||
}
|
||||
|
||||
componentDidUnload() {
|
||||
disconnectedCallback() {
|
||||
this.resizeObserver.unobserve(this.textarea);
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ export class Tooltip {
|
||||
this.syncOptions();
|
||||
}
|
||||
|
||||
componentDidUnload() {
|
||||
disconnectedCallback() {
|
||||
this.popover.destroy();
|
||||
|
||||
this.host.removeEventListener('blur', this.handleBlur, true);
|
||||
|
||||
Reference in New Issue
Block a user