11/**
2- * MIT License
3- *
4- * Copyright (c) 2025 Mickaël Canouil
5- *
6- * Permission is hereby granted, free of charge, to any person obtaining a copy
7- * of this software and associated documentation files (the "Software"), to deal
8- * in the Software without restriction, including without limitation the rights
9- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10- * copies of the Software, and to permit persons to whom the Software is
11- * furnished to do so, subject to the following conditions:
12- *
13- * The above copyright notice and this permission notice shall be included in all
14- * copies or substantial portions of the Software.
15- *
16- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22- * SOFTWARE.
23- */
24-
25- /**
26- * Author: Mickaël Canouil
27- * Version: 1.0.0
28- * License: MIT
29- * Source: https://github.com/mcanouil/quarto-revealjs-tabset
2+ * @module RevealJsTabset
3+ * @version 1.2.0
4+ * @license MIT
5+ * @copyright 2026 Mickaël Canouil
6+ * @author Mickaël Canouil
307 */
318
329window . RevealJsTabset = function ( ) {
@@ -52,7 +29,9 @@ window.RevealJsTabset = function () {
5229 * fragment triggers for tab navigation.
5330 */
5431 deck . on ( "ready" , function ( ) {
55- const tabsetSlides = document . querySelectorAll ( ".reveal .slides section .panel-tabset" ) ;
32+ const tabsetSlides = document . querySelectorAll (
33+ ".reveal .slides section .panel-tabset" ,
34+ ) ;
5635
5736 tabsetSlides . forEach ( function ( tabset ) {
5837 const tabs = tabset . querySelectorAll ( TAB_SELECTOR ) ;
@@ -81,6 +60,7 @@ window.RevealJsTabset = function () {
8160 fragmentDiv . dataset . tabIndex = i + 1 ;
8261 fragmentDiv . setAttribute ( "data-fragment-index" , currentIndex ) ;
8362 fragmentDiv . style . display = "none" ;
63+ fragmentDiv . setAttribute ( "aria-hidden" , "true" ) ;
8464 parentNode . appendChild ( fragmentDiv ) ;
8565 currentIndex ++ ;
8666 }
@@ -96,6 +76,7 @@ window.RevealJsTabset = function () {
9676 if ( ! event . fragment . classList . contains ( "panel-tabset-fragment" ) ) return ;
9777
9878 const tabIndex = parseInt ( event . fragment . dataset . tabIndex , 10 ) ;
79+ if ( isNaN ( tabIndex ) ) return ;
9980 const tabset = deck . getCurrentSlide ( ) . querySelector ( ".panel-tabset" ) ;
10081 if ( ! tabset ) return ;
10182
@@ -113,6 +94,7 @@ window.RevealJsTabset = function () {
11394 if ( ! event . fragment . classList . contains ( "panel-tabset-fragment" ) ) return ;
11495
11596 const tabIndex = parseInt ( event . fragment . dataset . tabIndex , 10 ) ;
97+ if ( isNaN ( tabIndex ) ) return ;
11698 const tabset = deck . getCurrentSlide ( ) . querySelector ( ".panel-tabset" ) ;
11799 if ( ! tabset ) return ;
118100
@@ -141,7 +123,7 @@ window.RevealJsTabset = function () {
141123 fragments . forEach ( function ( fragment ) {
142124 if ( fragment . classList . contains ( "visible" ) ) {
143125 const tabIndex = parseInt ( fragment . dataset . tabIndex , 10 ) ;
144- if ( tabIndex > activeTabIndex ) {
126+ if ( ! isNaN ( tabIndex ) && tabIndex > activeTabIndex ) {
145127 activeTabIndex = tabIndex ;
146128 }
147129 }
@@ -167,6 +149,11 @@ window.RevealJsTabset = function () {
167149
168150 panel . classList . toggle ( "active" , isActive ) ;
169151 panel . style . display = isActive ? "block" : "none" ;
152+ if ( isActive ) {
153+ panel . removeAttribute ( "hidden" ) ;
154+ } else {
155+ panel . setAttribute ( "hidden" , "" ) ;
156+ }
170157 } ) ;
171158 } ) ;
172159 } ) ;
0 commit comments