Twenty Twenty-One: Prevent Dark Mode related JavaScript error.
This prevents an `Uncaught TypeError` in the block editor when scrolling caused by the absence of a `#dark-mode-toggler` element. Props ocean90, mukesh27, justinahinon. Fixes #52473. Built from https://develop.svn.wordpress.org/trunk@50269 git-svn-id: http://core.svn.wordpress.org/trunk@49914 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d0c1e2b97b
commit
34987fe903
|
@ -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,14 +55,17 @@ 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;
|
||||
};
|
||||
|
||||
if ( toggler ) {
|
||||
window.addEventListener( 'scroll', checkScroll );
|
||||
}
|
||||
}
|
||||
|
||||
darkModeInitialLoad();
|
||||
darkModeRepositionTogglerOnScroll();
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue