@@ -71,11 +71,7 @@ export class TabContainerElement extends HTMLElement {
7171
7272 get #tabList( ) {
7373 const slot = this . #tabListSlot
74- if ( this . #tabListSlot. hasAttribute ( 'role' ) ) {
75- return slot
76- } else {
77- return slot . assignedNodes ( ) [ 0 ] as HTMLElement
78- }
74+ return slot . assignedNodes ( ) [ 0 ] as HTMLElement
7975 }
8076
8177 get #beforeTabsSlot( ) {
@@ -99,9 +95,6 @@ export class TabContainerElement extends HTMLElement {
9995 }
10096
10197 get #tabs( ) {
102- if ( this . #tabListSlot. matches ( '[role=tablist]' ) ) {
103- return this . #tabListSlot. assignedNodes ( ) as HTMLElement [ ]
104- }
10598 return Array . from ( this . #tabList?. querySelectorAll < HTMLElement > ( '[role="tab"]' ) || [ ] ) . filter (
10699 tab => tab instanceof HTMLElement && tab . closest ( this . tagName ) === this ,
107100 )
@@ -230,15 +223,17 @@ export class TabContainerElement extends HTMLElement {
230223 customTabList . setAttribute ( 'slot' , 'tablist' )
231224 }
232225 } else {
226+ const tabListElement = document . createElement ( 'div' )
227+ this . prepend ( tabListElement )
228+ tabListElement . append ( ...[ ...this . children ] . filter ( e => e . matches ( '[role=tab]' ) ) )
229+ tabListElement . role = 'tablist'
230+ tabListElement . style . display = 'block'
231+
233232 if ( manualSlotsSupported ) {
234- tabListSlot . assign ( ... [ ... this . children ] . filter ( e => e . matches ( '[role=tab]' ) ) )
233+ tabListSlot . assign ( tabListElement )
235234 } else {
236- for ( const e of this . children ) {
237- if ( e . matches ( '[role=tab]' ) ) e . setAttribute ( 'slot' , 'tablist' )
238- }
235+ tabListElement . setAttribute ( 'slot' , 'tablist' )
239236 }
240- tabListSlot . role = 'tablist'
241- tabListSlot . style . display = 'block'
242237 }
243238 const tabList = this . #tabList
244239 this . #reflectAttributeToShadow( 'aria-description' , tabList )
@@ -251,7 +246,7 @@ export class TabContainerElement extends HTMLElement {
251246 const afterSlotted : Element [ ] = [ ]
252247 let autoSlotted = beforeSlotted
253248 for ( const child of this . children ) {
254- if ( child . getAttribute ( 'role' ) === 'tab' || child . getAttribute ( 'role' ) === ' tablist') {
249+ if ( child . getAttribute ( 'role' ) === 'tablist' ) {
255250 autoSlotted = afterTabSlotted
256251 continue
257252 }
0 commit comments