aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2021-09-09 14:21:01 +0200
committerGitHub <noreply@github.com>2021-09-09 14:21:01 +0200
commit13b6fd962bb4d43bb494ab9d336495b32a1f2d0b (patch)
tree0af75eaa1f7ced2414d3abe3c0e7c33477428b1c /plugins
parentbe7dba72bd46bd4f34556662cd1547eae3f2a836 (diff)
downloaddokka-13b6fd962bb4d43bb494ab9d336495b32a1f2d0b.tar.gz
dokka-13b6fd962bb4d43bb494ab9d336495b32a1f2d0b.tar.bz2
dokka-13b6fd962bb4d43bb494ab9d336495b32a1f2d0b.zip
Fix js error on pages without tabs (#2127)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/src/main/resources/dokka/scripts/platform-content-handler.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/plugins/base/src/main/resources/dokka/scripts/platform-content-handler.js b/plugins/base/src/main/resources/dokka/scripts/platform-content-handler.js
index ff1bf3d9..64a1ce53 100644
--- a/plugins/base/src/main/resources/dokka/scripts/platform-content-handler.js
+++ b/plugins/base/src/main/resources/dokka/scripts/platform-content-handler.js
@@ -42,8 +42,7 @@ const darkModeSwitch = () => {
const darkModeEnabled = enabledClasses.contains("theme-dark")
if (darkModeEnabled) {
initPlayground(samplesDarkThemeName)
- }
- else {
+ } else {
initPlayground(samplesLightThemeName)
}
localStorage.setItem(localStorageKey, JSON.stringify(darkModeEnabled))
@@ -51,7 +50,7 @@ const darkModeSwitch = () => {
}
const initPlayground = (theme) => {
- if(!samplesAreEnabled()) return
+ if (!samplesAreEnabled()) return
instances.forEach(instance => instance.destroy())
instances = []
@@ -171,10 +170,13 @@ function initTabs() {
}
function showCorrespondingTabBody(element) {
- const key = element.querySelector("button[data-active]").getAttribute("data-togglable")
- document.querySelector(".tabs-section-body")
- .querySelector("div[data-togglable='" + key + "']")
- .setAttribute("data-active", "")
+ const buttonWithKey = element.querySelector("button[data-active]")
+ if (buttonWithKey) {
+ const key = buttonWithKey.getAttribute("data-togglable")
+ document.querySelector(".tabs-section-body")
+ .querySelector("div[data-togglable='" + key + "']")
+ .setAttribute("data-active", "")
+ }
}
function filterButtonHandler(event) {