@@ -45,6 +45,42 @@ describe('tab-container', function () {
4545 } )
4646 } )
4747
48+ describe ( 'after tree insertion with aria-selected on second tab' , function ( ) {
49+ beforeEach ( function ( ) {
50+ document . body . innerHTML = `
51+ <tab-container>
52+ <button type="button" role="tab">Tab one</button>
53+ <button type="button" role="tab" aria-selected="true">Tab two</button>
54+ <button type="button" role="tab">Tab three</button>
55+ <div role="tabpanel" hidden>
56+ Panel 1
57+ </div>
58+ <div role="tabpanel">
59+ Panel 2
60+ </div>
61+ <div role="tabpanel" hidden data-tab-container-no-tabstop>
62+ Panel 3
63+ </div>
64+ </tab-container>
65+ `
66+ tabContainer = document . querySelector ( 'tab-container' )
67+ tabs = Array . from ( document . querySelectorAll ( 'button' ) )
68+ panels = Array . from ( document . querySelectorAll ( '[role="tabpanel"]' ) )
69+ events = [ ]
70+ tabContainer . addEventListener ( 'tab-container-change' , e => events . push ( e ) )
71+ tabContainer . addEventListener ( 'tab-container-changed' , e => events . push ( e ) )
72+ } )
73+
74+ afterEach ( function ( ) {
75+ document . body . innerHTML = ''
76+ } )
77+
78+ it ( 'the second tab is still selected' , function ( ) {
79+ assert . deepStrictEqual ( tabs . map ( isSelected ) , [ false , true , false ] , 'Second tab is selected' )
80+ assert . deepStrictEqual ( panels . map ( isHidden ) , [ true , false , true ] , 'Second panel is visible' )
81+ } )
82+ } )
83+
4884 describe ( 'after tree insertion' , function ( ) {
4985 beforeEach ( function ( ) {
5086 document . body . innerHTML = `
0 commit comments