diff --git a/functions.php b/functions.php index 1d8f4a8..b7e5ffb 100644 --- a/functions.php +++ b/functions.php @@ -153,7 +153,7 @@ function radiate_scripts() { // Add Genericons, used in the main stylesheet. wp_enqueue_style( 'radiate-genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.3.1' ); - wp_enqueue_script( 'radiate-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20120206', true ); + wp_enqueue_script( 'radiate-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20260930', true ); wp_enqueue_script( 'radiate-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true ); diff --git a/js/navigation.js b/js/navigation.js index d276f4a..5b773bd 100644 --- a/js/navigation.js +++ b/js/navigation.js @@ -81,6 +81,10 @@ jQuery(document).ready(function() { var container; container = document.getElementById( 'site-navigation' ); + if ( ! container ) { + return; + } + /** * Toggles `focus` class to allow submenu access on tablets. */ diff --git a/tests/e2e/specs/mobile-menu/navigation-missing-container.spec.ts b/tests/e2e/specs/mobile-menu/navigation-missing-container.spec.ts new file mode 100644 index 0000000..a629e1b --- /dev/null +++ b/tests/e2e/specs/mobile-menu/navigation-missing-container.spec.ts @@ -0,0 +1,34 @@ +import { test, expect } from "../../fixtures"; + +/** + * @area mobile-menu + * @tier fresh + * @guards themegrill/radiate-pro#28 + * @source fix/28-navigation-guard 2026-09-30; js/navigation.js + * @why The touch-submenu handler in navigation.js read #site-navigation + * without a null check (the first handler already had one), so any page + * without that element (a child theme whose header.php drops the nav) + * threw "Cannot read properties of null (reading 'querySelectorAll')". + * Removes the