Use disconnectedCallback instead of componentDidUnload; fixes #161

pull/165/head
Cory LaViska 2020-08-06 06:56:29 -04:00
rodzic 60befc34d3
commit 80fa1cea83
11 zmienionych plików z 12 dodań i 11 usunięć

Wyświetl plik

@ -34,8 +34,9 @@ export class Card {
this.host.shadowRoot.addEventListener('slotchange', this.updateSlots); this.host.shadowRoot.addEventListener('slotchange', this.updateSlots);
} }
componentDidUnload() { disconnectedCallback() {
this.host.shadowRoot.removeEventListener('slotchange', this.updateSlots); this.host.shadowRoot.removeEventListener('slotchange', this.updateSlots);
console.log('cleanup');
} }
updateSlots() { updateSlots() {

Wyświetl plik

@ -69,7 +69,7 @@ export class Details {
} }
} }
componentDidUnload() { disconnectedCallback() {
focusVisible.unobserve(this.details); focusVisible.unobserve(this.details);
} }

Wyświetl plik

@ -90,7 +90,7 @@ export class Dialog {
} }
} }
componentDidUnload() { disconnectedCallback() {
unlockBodyScrolling(this.host); unlockBodyScrolling(this.host);
this.host.shadowRoot.removeEventListener('slotchange', this.updateSlots); this.host.shadowRoot.removeEventListener('slotchange', this.updateSlots);

Wyświetl plik

@ -98,7 +98,7 @@ export class Drawer {
} }
} }
componentDidUnload() { disconnectedCallback() {
unlockBodyScrolling(this.host); unlockBodyScrolling(this.host);
this.host.shadowRoot.removeEventListener('slotchange', this.updateSlots); this.host.shadowRoot.removeEventListener('slotchange', this.updateSlots);

Wyświetl plik

@ -118,7 +118,7 @@ export class Dropdown {
} }
} }
componentDidUnload() { disconnectedCallback() {
this.hide(); this.hide();
this.popover.destroy(); this.popover.destroy();
} }

Wyświetl plik

@ -32,7 +32,7 @@ export class IconButton {
focusVisible.observe(this.button); focusVisible.observe(this.button);
} }
componentDidUnload() { disconnectedCallback() {
focusVisible.unobserve(this.button); focusVisible.unobserve(this.button);
} }

Wyświetl plik

@ -74,7 +74,7 @@ export class Rating {
focusVisible.observe(this.rating); focusVisible.observe(this.rating);
} }
componentDidUnload() { disconnectedCallback() {
focusVisible.unobserve(this.rating); focusVisible.unobserve(this.rating);
} }

Wyświetl plik

@ -121,7 +121,7 @@ export class Select {
requestAnimationFrame(() => this.syncItemsFromValue()); requestAnimationFrame(() => this.syncItemsFromValue());
} }
componentDidUnload() { disconnectedCallback() {
this.menu.querySelector('slot').removeEventListener('slotchange', this.handleSlotChange); this.menu.querySelector('slot').removeEventListener('slotchange', this.handleSlotChange);
} }

Wyświetl plik

@ -88,7 +88,7 @@ export class TabGroup {
this.mutationObserver.observe(this.host, { attributes: true, childList: true, subtree: true }); this.mutationObserver.observe(this.host, { attributes: true, childList: true, subtree: true });
} }
componentDidUnload() { disconnectedCallback() {
this.mutationObserver.disconnect(); this.mutationObserver.disconnect();
focusVisible.unobserve(this.tabGroup); focusVisible.unobserve(this.tabGroup);
this.resizeObserver.unobserve(this.nav); this.resizeObserver.unobserve(this.nav);

Wyświetl plik

@ -114,7 +114,7 @@ export class Textarea {
this.resizeObserver.observe(this.textarea); this.resizeObserver.observe(this.textarea);
} }
componentDidUnload() { disconnectedCallback() {
this.resizeObserver.unobserve(this.textarea); this.resizeObserver.unobserve(this.textarea);
} }

Wyświetl plik

@ -114,7 +114,7 @@ export class Tooltip {
this.syncOptions(); this.syncOptions();
} }
componentDidUnload() { disconnectedCallback() {
this.popover.destroy(); this.popover.destroy();
this.host.removeEventListener('blur', this.handleBlur, true); this.host.removeEventListener('blur', this.handleBlur, true);