Skip to content

Commit 9c5636c

Browse files
guard a couple (possibly null) querySelector results (#1860)
when looking into the cause of #1829 I found a couple cases where `document.querySelector` might be `null` and we don't handle that very gracefully. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent c409625 commit 9c5636c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ function debounce(callback, wait) {
775775
*/
776776
async function setupAnnouncementBanner() {
777777
const banner = document.querySelector(".bd-header-announcement");
778-
const { pstAnnouncementUrl } = banner.dataset;
778+
const { pstAnnouncementUrl } = banner ? banner.dataset : null;
779779

780780
if (!pstAnnouncementUrl) {
781781
return;
@@ -812,6 +812,9 @@ async function fetchRevealBannersTogether() {
812812
// to hidden, and an animation transition on the height (unless the user has
813813
// turned off animations)
814814
const revealer = document.querySelector(".pst-async-banner-revealer");
815+
if (!revealer) {
816+
return;
817+
}
815818

816819
// Remove the d-none (display-none) class to calculate the children heights.
817820
revealer.classList.remove("d-none");

0 commit comments

Comments
 (0)