Skip to content
Snippets Groups Projects
Commit 58006712 authored by Steinwender, Tamara's avatar Steinwender, Tamara
Browse files

Add sanity checks

parent bd02e5a1
No related branches found
No related tags found
No related merge requests found
Pipeline #85414 passed
...@@ -81,6 +81,9 @@ export class ColorMode extends ScopedElementsMixin(DBPLitElement) { ...@@ -81,6 +81,9 @@ export class ColorMode extends ScopedElementsMixin(DBPLitElement) {
toggleModeMenu() { toggleModeMenu() {
const button = this.shadowRoot.querySelector(".mode-button"); const button = this.shadowRoot.querySelector(".mode-button");
if(!button) {
return;
}
if (button.classList.contains("active")) if (button.classList.contains("active"))
button.classList.remove("active"); button.classList.remove("active");
else else
...@@ -116,10 +119,15 @@ export class ColorMode extends ScopedElementsMixin(DBPLitElement) { ...@@ -116,10 +119,15 @@ export class ColorMode extends ScopedElementsMixin(DBPLitElement) {
loadTheme(themeName) { loadTheme(themeName) {
const button = this.shadowRoot.querySelector(".button-" + themeName); const button = this.shadowRoot.querySelector(".button-" + themeName);
const otherButtons = this.shadowRoot.querySelectorAll(".button-theme"); const otherButtons = this.shadowRoot.querySelectorAll(".button-theme");
const body = this.shadowRoot.host.getRootNode({composed: true}).body;
if (button === null || otherButtons.length === 0 || body === null ) {
return;
}
otherButtons.forEach(button => button.classList.remove("active")); otherButtons.forEach(button => button.classList.remove("active"));
button.classList.add("active"); button.classList.add("active");
const body = this.shadowRoot.host.getRootNode({composed: true}).body;
if (!body.classList.contains(themeName)) { if (!body.classList.contains(themeName)) {
this.themes.forEach(theme => { this.themes.forEach(theme => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment