Fix scrolling to sections if a tab's hash coincides with one

ben10/wiki/Alien_X_(Classic)#Appearances
This commit is contained in:
blankie 2023-11-13 14:35:07 +11:00
parent b60e000513
commit ce773b059e
Signed by: blankie
GPG key ID: CC15FC822C7F61F5

View file

@ -66,6 +66,9 @@ function setCurrentTab(tabber, tab, content) {
tab.classList.add("wds-is-current"); tab.classList.add("wds-is-current");
content.classList.add("wds-is-current"); content.classList.add("wds-is-current");
if (tab.dataset.hash) { if (tab.dataset.hash) {
location.hash = "#" + tab.dataset.hash; let fragment = "#" + tab.dataset.hash;
if (location.hash !== fragment) {
history.pushState(null, "", fragment);
}
} }
} }