Skip to content

Commit

Permalink
guard a couple (possibly null) querySelector results (#1860)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
drammock and pre-commit-ci[bot] authored Jun 12, 2024
1 parent c409625 commit 9c5636c
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ function debounce(callback, wait) {
*/
async function setupAnnouncementBanner() {
const banner = document.querySelector(".bd-header-announcement");
const { pstAnnouncementUrl } = banner.dataset;
const { pstAnnouncementUrl } = banner ? banner.dataset : null;

if (!pstAnnouncementUrl) {
return;
Expand Down Expand Up @@ -812,6 +812,9 @@ async function fetchRevealBannersTogether() {
// to hidden, and an animation transition on the height (unless the user has
// turned off animations)
const revealer = document.querySelector(".pst-async-banner-revealer");
if (!revealer) {
return;
}

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

0 comments on commit 9c5636c

Please sign in to comment.