Permalink
Browse files

Twenty Twelve: avoid JavaScript errors if navigation wrapper markup i…

…s removed from header. Fixes #22307.

git-svn-id: http://core.svn.wordpress.org/trunk@22574 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
1 parent b59a52a commit 8f17fa783a4acd7c75f753ca1a487c1abf82830f @nanobar nanobar committed Nov 14, 2012
Showing with 9 additions and 7 deletions.
  1. +9 −7 wp-content/themes/twentytwelve/js/navigation.js
@@ -4,16 +4,18 @@
* Handles toggling the navigation menu for small screens.
*/
( function() {
- var button = document.getElementById( 'site-navigation' ).getElementsByTagName( 'h3' )[0],
- menu = document.getElementById( 'site-navigation' ).getElementsByTagName( 'ul' )[0];
-
- if ( undefined === button )
- return false;
+ var nav = document.getElementById( 'site-navigation' ), button, menu;
+ if ( ! nav )
+ return;
+ button = nav.getElementsByTagName( 'h3' )[0];
+ menu = nav.getElementsByTagName( 'ul' )[0];
+ if ( ! button )
+ return;
// Hide button if menu is missing or empty.
- if ( undefined === menu || ! menu.childNodes.length ) {
+ if ( ! menu || ! menu.childNodes.length ) {
button.style.display = 'none';
- return false;
+ return;
}
button.onclick = function() {

0 comments on commit 8f17fa7

Please sign in to comment.