File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ export default Base.extend({
2828
2929 var self = this ;
3030
31+ const autotocInstances = $ ( ".pat-autotoc" ) ;
32+ self . instanceIndex = autotocInstances . index ( self . $el ) ;
33+
3134 const $nav = $ ( "<nav/>" )
3235 . attr ( "aria-label" , "Tab Navigation" ) ;
3336
@@ -81,7 +84,7 @@ export default Base.extend({
8184 const $section = $level . closest ( self . options . section ) ;
8285 let sectionId = $section . prop ( "id" ) ;
8386 let sectionHash = `#${ sectionId } ` ;
84- const tabId = `${ self . options . IDPrefix } ${ self . name } -${ i } ` ;
87+ const tabId = `${ self . options . IDPrefix } ${ self . name } -${ self . instanceIndex } - ${ i } ` ;
8588 const tabHash = `#${ tabId } ` ;
8689 const levelId = `${ tabId } -pane` ;
8790 const levelHash = `#${ levelId } ` ;
Original file line number Diff line number Diff line change @@ -58,12 +58,10 @@ describe("1 - AutoTOC", function () {
5858 await utils . timeout ( 1 ) ;
5959
6060 const firstTab = document . querySelectorAll ( ".nav > li > a" ) [ 0 ]
61- expect ( firstTab . getAttribute ( "id" ) ) . toEqual (
62- "autotoc-item-autotoc-0"
61+ expect ( firstTab . getAttribute ( "id" ) ) . toEqual ( "autotoc-item-autotoc-0-0" ) ;
62+ expect ( firstTab . getAttribute ( "data-bs-target" ) ) . toEqual (
63+ "#autotoc-item-autotoc-0-0-pane" ,
6364 ) ;
64- expect (
65- firstTab . getAttribute ( "data-bs-target" )
66- ) . toEqual ( "#autotoc-item-autotoc-0-pane" ) ;
6765 } ) ;
6866 it ( "can have custom levels" , async function ( ) {
6967 this . $el . attr ( "data-pat-autotoc" , "levels: h1" ) ;
You can’t perform that action at this time.
0 commit comments