@@ -109,7 +109,7 @@ export class TabContainerElement extends HTMLElement {
109
109
110
110
static observedAttributes = [ 'vertical' ]
111
111
112
- get #tabList( ) {
112
+ get #tabList( ) : HTMLElement {
113
113
const wrapper = this . querySelector ( '[slot=tablist-wrapper]' )
114
114
if ( wrapper ?. closest ( this . tagName ) === this ) {
115
115
return wrapper . querySelector ( '[role=tablist]' ) as HTMLElement
@@ -220,8 +220,20 @@ export class TabContainerElement extends HTMLElement {
220
220
this . addEventListener ( 'keydown' , this )
221
221
this . addEventListener ( 'click' , this )
222
222
223
- this . selectTab ( - 1 )
224
- this . #setupComplete = true
223
+ if ( this . #tabs. length > 0 ) {
224
+ this . selectTab ( - 1 )
225
+ this . #setupComplete = true
226
+ } else {
227
+ const mutationObserver = new MutationObserver ( ( ) => {
228
+ if ( this . #tabs. length > 0 ) {
229
+ this . selectTab ( - 1 )
230
+ this . #setupComplete = true
231
+ mutationObserver . disconnect ( )
232
+ }
233
+ } )
234
+
235
+ mutationObserver . observe ( this , { childList : true , subtree : true } )
236
+ }
225
237
}
226
238
227
239
attributeChangedCallback ( name : string ) {
@@ -356,7 +368,7 @@ export class TabContainerElement extends HTMLElement {
356
368
* Out of bounds index
357
369
*/
358
370
if ( index > tabs . length - 1 ) {
359
- throw new RangeError ( `Index " ${ index } " out of bounds` )
371
+ return
360
372
}
361
373
362
374
const selectedTab = tabs [ index ]
0 commit comments