From 170dbbf166a713f4ffe9fa87f40784eb3d505855 Mon Sep 17 00:00:00 2001 From: Hrithik Dalal Date: Mon, 2 Nov 2026 09:03:15 +0530 Subject: [PATCH] Twenty Nineteen: Prevent a console error when tapping a `#` menu link without a submenu. On touch screens, tapping a top-level menu item with a `#` URL checks whether the next sibling is the submenu toggle. Items without children have no next sibling, so this threw a TypeError. Use `nextElementSibling` and check it exists before calling `matches()`. Follow-up to [55970]. See #45903. --- src/wp-content/themes/twentynineteen/functions.php | 2 +- .../themes/twentynineteen/js/touch-keyboard-navigation.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-content/themes/twentynineteen/functions.php b/src/wp-content/themes/twentynineteen/functions.php index 987c13c22f019..5ed0e68e7ce4f 100644 --- a/src/wp-content/themes/twentynineteen/functions.php +++ b/src/wp-content/themes/twentynineteen/functions.php @@ -282,7 +282,7 @@ function twentynineteen_scripts() { 'twentynineteen-touch-navigation', get_theme_file_uri( '/js/touch-keyboard-navigation.js' ), array(), - '20250802', + '20261102', array( 'in_footer' => true, 'strategy' => 'defer', diff --git a/src/wp-content/themes/twentynineteen/js/touch-keyboard-navigation.js b/src/wp-content/themes/twentynineteen/js/touch-keyboard-navigation.js index 74a7886d8c1bf..c846d0a10d5a8 100644 --- a/src/wp-content/themes/twentynineteen/js/touch-keyboard-navigation.js +++ b/src/wp-content/themes/twentynineteen/js/touch-keyboard-navigation.js @@ -220,7 +220,7 @@ var url = event.target.getAttribute( 'href' ) ? event.target.getAttribute( 'href' ) : ''; // Open submenu if URL is #. - if ( '#' === url && event.target.nextSibling.matches('.submenu-expand') ) { + if ( '#' === url && event.target.nextElementSibling && event.target.nextElementSibling.matches('.submenu-expand') ) { openSubMenu( event.target ); } }