diff --git a/wp-content/themes/twentytwentyone/assets/js/dark-mode-toggler.js b/wp-content/themes/twentytwentyone/assets/js/dark-mode-toggler.js index 22f5e3e15f..f5519d06e4 100644 --- a/wp-content/themes/twentytwentyone/assets/js/dark-mode-toggler.js +++ b/wp-content/themes/twentytwentyone/assets/js/dark-mode-toggler.js @@ -44,7 +44,9 @@ function darkModeInitialLoad() { } function darkModeRepositionTogglerOnScroll() { - var prevScroll = window.scrollY || document.documentElement.scrollTop, + + var toggler = document.getElementById( 'dark-mode-toggler' ), + prevScroll = window.scrollY || document.documentElement.scrollTop, currentScroll, checkScroll = function() { @@ -53,13 +55,16 @@ function darkModeRepositionTogglerOnScroll() { currentScroll + ( window.innerHeight * 1.5 ) > document.body.clientHeight || currentScroll < prevScroll ) { - document.getElementById( 'dark-mode-toggler' ).classList.remove( 'hide' ); + toggler.classList.remove( 'hide' ); } else if ( currentScroll > prevScroll && 250 < currentScroll ) { - document.getElementById( 'dark-mode-toggler' ).classList.add( 'hide' ); + toggler.classList.add( 'hide' ); } prevScroll = currentScroll; }; - window.addEventListener( 'scroll', checkScroll ); + + if ( toggler ) { + window.addEventListener( 'scroll', checkScroll ); + } } darkModeInitialLoad(); diff --git a/wp-includes/version.php b/wp-includes/version.php index 0ea947b054..ccbac47a1a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.7-beta1-50268'; +$wp_version = '5.7-beta1-50269'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.