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

* Add check for undefined element on disconnect

* Fix prettier error
This commit is contained in:
Susanne Kirchner
2024-10-16 16:53:11 +02:00
committed by GitHub
parent 2c66c859d6
commit b14498822b
2 changed files with 11 additions and 1 deletions

View File

@@ -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() {

View File

@@ -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>