Prevent linking to tabs with no IDs

This commit is contained in:
blankie 2023-05-30 14:01:14 +07:00
parent 458cce1c5c
commit 9ff6d3b9a8
Signed by: blankie
GPG key ID: CC15FC822C7F61F5

View file

@ -14,7 +14,6 @@ for (let tabber of document.body.querySelectorAll(".wds-tabber")) {
});
if (tab.dataset.hash === tabToFind) {
setCurrentTab(tabber, tab, content);
tabToFind = null;
}
}
}
@ -66,6 +65,8 @@ function setCurrentTab(tabber, tab, content) {
tab.classList.add("wds-is-current");
content.classList.add("wds-is-current");
location.hash = "#" + tab.dataset.hash;
history.pushState(null, "", "#" + tab.dataset.hash);
if (tab.dataset.hash) {
location.hash = "#" + tab.dataset.hash;
history.pushState(null, "", "#" + tab.dataset.hash);
}
}