From f9ab214c4a33d1bcb52116e5b5572392e0b553dd Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Wed, 5 Jul 2023 11:46:39 -0400 Subject: [PATCH] tabpane: use `data-` attribute instead of class name --- layouts/shortcodes/tabpane.html | 16 ++++++------ static/js/tabpane-persist.js | 46 ++++++++++++++++++++------------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/layouts/shortcodes/tabpane.html b/layouts/shortcodes/tabpane.html index d6689f2d65..beda48917e 100644 --- a/layouts/shortcodes/tabpane.html +++ b/layouts/shortcodes/tabpane.html @@ -1,4 +1,7 @@ {{/* Check parameter types */ -}} + +{{ $tpPersistAttrName := "data-td-tp-persist" -}} + {{ with .Get "langEqualsHeader" -}} {{ if ne ( printf "%T" . ) "bool" -}} {{ errorf "Shortcode %q: boolean value expected for parameter %q, but got %s. Error position: %s" $.Name "langEqualsHeader" (printf "%T" .) $.Position -}} @@ -81,6 +84,7 @@ {{ else if eq $persistKeyKind "header" -}} {{ $persistKey = $element.header -}} {{ end -}} + {{ $persistKey = $persistKey | lower -}} {{/* Check for duplicate tab-persistence keys */ -}} {{ if and $persistTab $persistKey -}} @@ -98,8 +102,6 @@ {{ $rightpush = . -}} {{ end -}} - {{/* Replace by "-" all chars that are not valid in a CSS class name: */ -}} - {{ $persistKey = replaceRE "[^a-zA-Z0-9_-]" "-" $persistKey | lower -}}