sl-tab-group throws error if unmounted too fast (#2218)

* Add check for undefined element on disconnect

* Fix prettier error
konnorrogers/add-changelog-entry-for-2218
Susanne Kirchner 2024-10-16 16:53:11 +02:00 zatwierdzone przez GitHub
rodzic 2c66c859d6
commit b14498822b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
2 zmienionych plików z 11 dodań i 1 usunięć

Wyświetl plik

@ -128,7 +128,10 @@ export default class SlTabGroup extends ShoelaceElement {
disconnectedCallback() {
super.disconnectedCallback();
this.mutationObserver?.disconnect();
this.resizeObserver?.unobserve(this.nav);
if (this.nav) {
this.resizeObserver?.unobserve(this.nav);
}
}
private getAllTabs() {

Wyświetl plik

@ -84,6 +84,13 @@ describe('<sl-tab-group>', () => {
expect(tabGroup).to.be.visible;
});
it('should not throw error when unmounted too fast', async () => {
const el = await fixture(html` <div></div> `);
el.innerHTML = '<sl-tab-group></sl-tab-group>';
el.innerHTML = '';
});
it('is accessible', async () => {
const tabGroup = await fixture<SlTabGroup>(html`
<sl-tab-group>