@@ -109,7 +109,7 @@ export class TabContainerElement extends HTMLElement {
109109
110110 static observedAttributes = [ 'vertical' ]
111111
112- get #tabList( ) {
112+ get #tabList( ) : HTMLElement {
113113 const wrapper = this . querySelector ( '[slot=tablist-wrapper]' )
114114 if ( wrapper ?. closest ( this . tagName ) === this ) {
115115 return wrapper . querySelector ( '[role=tablist]' ) as HTMLElement
@@ -220,8 +220,20 @@ export class TabContainerElement extends HTMLElement {
220220 this . addEventListener ( 'keydown' , this )
221221 this . addEventListener ( 'click' , this )
222222
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+ }
225237 }
226238
227239 attributeChangedCallback ( name : string ) {
@@ -356,7 +368,7 @@ export class TabContainerElement extends HTMLElement {
356368 * Out of bounds index
357369 */
358370 if ( index > tabs . length - 1 ) {
359- throw new RangeError ( `Index " ${ index } " out of bounds` )
371+ return
360372 }
361373
362374 const selectedTab = tabs [ index ]
0 commit comments