Skip to content

Commit e033574

Browse files
authored
fix null check for invalid lang router (#3823)
A temp solution to solve the problem of 404 page error: null check is missing before accessing the child props of `currentLangElement`.
1 parent 6684795 commit e033574

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

static/js/main.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020
}
2121
})
2222

23-
langPickerTogglerElement.setAttribute('title', currentLangElement.textContent)
23+
if (currentLangElement) {
24+
langPickerTogglerElement.setAttribute('title', currentLangElement.textContent)
2425

25-
// Remove the current selected language item, because we don't need to choose it
26-
// any more unless we want to switch to a new language
27-
langPickerElement.removeChild(currentLangElement.parentNode)
26+
// Remove the current selected language item, because we don't need to choose it
27+
// any more unless we want to switch to a new language
28+
langPickerElement.removeChild(currentLangElement.parentNode)
29+
}
2830

2931
langPickerTogglerElement.addEventListener('click', function () {
3032
langPickerElement.classList.toggle('hidden')

0 commit comments

Comments
 (0)