@@ -420,7 +420,38 @@ <h1>Tab 2 Content</h1>
420420 test ( "it should show the correct tab if there is a querystring parameter in the URL" , done => {
421421 // the parameter should be equal to the id of the tabset
422422 // the value should be equal to the id of the tab you want opened
423- const searchParams = new URLSearchParams ( window . location . search )
423+ const searchParams = new URLSearchParams ( ) ;
424+ searchParams . set ( "fromQueryString" , "fromQueryStringTab2" ) ;
425+ var newPath = window . location . pathname + '?' + searchParams . toString ( ) ;
426+ history . pushState ( null , '' , newPath ) ;
427+
428+ const fragment = document . createRange ( ) . createContextualFragment ( `
429+ <pfe-tabs id="fromQueryString">
430+ <pfe-tab role="heading" slot="tab" id="fromQueryStringTab1">Tab 1</pfe-tab>
431+ <pfe-tab-panel role="region" slot="panel">Content</pfe-tab-panel>
432+ <pfe-tab role="heading" slot="tab" id="fromQueryStringTab2">Tab 2</pfe-tab>
433+ <pfe-tab-panel role="region" slot="panel">Content</pfe-tab-panel>
434+ </pfe-tabs>
435+ ` ) ;
436+
437+ document . body . appendChild ( fragment ) ;
438+
439+ flush ( ( ) => {
440+ const tabs = document . querySelector ( "#fromQueryString" ) ;
441+ const tab2 = tabs . querySelector ( "#fromQueryStringTab2" ) ;
442+ assert . equal ( tabs . selectedIndex , 1 ) ;
443+ assert . isTrue ( tab2 . hasAttribute ( "aria-selected" ) ) ;
444+
445+ document . body . removeChild ( tabs ) ;
446+ done ( ) ;
447+ } ) ;
448+ } ) ;
449+
450+ test ( "it should continue to support the \"pfe-\" prefix in the URL and show the correct tab if there is a querystring parameter in the URL" , done => {
451+ // this supports any tabs that are currently using the "pfe-" prefix
452+ // in the URL to open to a specific tab. the "pfe-" prefix has been
453+ // deprecated and should no longer be used
454+ const searchParams = new URLSearchParams ( ) ;
424455 searchParams . set ( "pfe-fromQueryString" , "fromQueryStringTab2" ) ;
425456 var newPath = window . location . pathname + '?' + searchParams . toString ( ) ;
426457 history . pushState ( null , '' , newPath ) ;
@@ -483,7 +514,7 @@ <h1>Tab 2 Content</h1>
483514
484515 flush ( ( ) => {
485516 const urlSearchParams = new URLSearchParams ( window . location . search ) ;
486- assert . equal ( urlSearchParams . get ( "pfe- history" ) , "historyTab2" ) ;
517+ assert . equal ( urlSearchParams . get ( "history" ) , "historyTab2" ) ;
487518 assert . equal ( tabs . selectedIndex , 1 ) ;
488519 assert . isTrue ( tab2 . hasAttribute ( "aria-selected" ) ) ;
489520 done ( ) ;
@@ -500,7 +531,7 @@ <h1>Tab 2 Content</h1>
500531
501532 flush ( ( ) => {
502533 const urlSearchParams = new URLSearchParams ( window . location . search ) ;
503- assert . equal ( urlSearchParams . get ( "pfe- history" ) , "historyTab2" ) ;
534+ assert . equal ( urlSearchParams . get ( "history" ) , "historyTab2" ) ;
504535 assert . equal ( tabs . selectedIndex , 0 ) ;
505536 assert . isTrue ( tab1 . hasAttribute ( "aria-selected" ) ) ;
506537 done ( ) ;
0 commit comments