Twenty Twelve: avoid JavaScript errors if navigation wrapper markup is removed from header. Fixes #22307.
git-svn-id: http://core.svn.wordpress.org/trunk@22574 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b59a52a77c
commit
8f17fa783a
|
@ -4,16 +4,18 @@
|
||||||
* Handles toggling the navigation menu for small screens.
|
* Handles toggling the navigation menu for small screens.
|
||||||
*/
|
*/
|
||||||
( function() {
|
( function() {
|
||||||
var button = document.getElementById( 'site-navigation' ).getElementsByTagName( 'h3' )[0],
|
var nav = document.getElementById( 'site-navigation' ), button, menu;
|
||||||
menu = document.getElementById( 'site-navigation' ).getElementsByTagName( 'ul' )[0];
|
if ( ! nav )
|
||||||
|
return;
|
||||||
if ( undefined === button )
|
button = nav.getElementsByTagName( 'h3' )[0];
|
||||||
return false;
|
menu = nav.getElementsByTagName( 'ul' )[0];
|
||||||
|
if ( ! button )
|
||||||
|
return;
|
||||||
|
|
||||||
// Hide button if menu is missing or empty.
|
// Hide button if menu is missing or empty.
|
||||||
if ( undefined === menu || ! menu.childNodes.length ) {
|
if ( ! menu || ! menu.childNodes.length ) {
|
||||||
button.style.display = 'none';
|
button.style.display = 'none';
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
button.onclick = function() {
|
button.onclick = function() {
|
||||||
|
|
Loading…
Reference in New Issue