@@ -11,7 +11,6 @@ const initTabs = () => {
1111 if ( container . classList . contains ( 'has-js' ) ) return // Already initialized
1212
1313 const primary = container . querySelector ( '.primary' )
14- const primaryItems = container . querySelectorAll ( '.primary > li:not(.-more)' )
1514
1615 // Add a class to turn off graceful degradation style
1716 container . classList . add ( 'has-js' )
@@ -28,7 +27,6 @@ const initTabs = () => {
2827 </li>
2928 ` )
3029 const secondary = container . querySelector ( '.-secondary' )
31- const secondaryItems = secondary . querySelectorAll ( 'li' )
3230 const allItems = container . querySelectorAll ( 'li' )
3331 const moreLi = primary . querySelector ( '.-more' )
3432 const moreBtn = moreLi . querySelector ( 'button' )
@@ -188,7 +186,10 @@ const initTabs = () => {
188186
189187// Initialize on page load and after Turbo navigates
190188// turbo:load fires on both initial page load and subsequent Turbo navigations
191- document . addEventListener ( 'turbo:load' , initTabs )
189+ if ( ! window . __timdexSourceTabsTurboListenerAdded ) {
190+ window . __timdexSourceTabsTurboListenerAdded = true
191+ document . addEventListener ( 'turbo:load' , initTabs )
192+ }
192193
193194// Run immediately in case turbo:load already fired before this script loaded
194195// (happens on first search when Turbo Drive loads the page containing this script)
0 commit comments