mirror of
git://develop.git.wordpress.org/
synced 2025-03-22 13:00:29 +01:00
Twenty Twenty-One: Check if anchor exists before triggering in-page navigation.
This prevents JavaScript errors when using hash in URLs without matching them to any existing anchor in the page. Props rixeo, sabernhardt, pbearne. Fixes #53619. git-svn-id: https://develop.svn.wordpress.org/trunk@52213 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c08e51cc88
commit
48fe42e9d2
@ -180,7 +180,9 @@ function twentytwentyoneExpandSubMenu( el ) { // jshint ignore:line
|
||||
// Wait 550 and scroll to the anchor.
|
||||
setTimeout(function () {
|
||||
var anchor = document.getElementById(event.target.hash.slice(1));
|
||||
anchor.scrollIntoView();
|
||||
if ( anchor ) {
|
||||
anchor.scrollIntoView();
|
||||
}
|
||||
}, 550);
|
||||
}
|
||||
} );
|
||||
|
Loading…
x
Reference in New Issue
Block a user