WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#22307 closed defect (bug)

Twenty Twelve: JavaScript error if not removed navigation wrapper markup — at Version 5

Reported by: sswells Owned by:
Milestone: 3.5 Priority: normal
Severity: normal Version:
Component: Bundled Theme Keywords: has-patch
Focuses: Cc:

Description (last modified by lancewillett)

I'm getting this error on a page that isn't using the header or nav. [Edit by lancewillett: This only occurs when the entire nav markup is removed.]

Error: TypeError: document.getElementById("site-navigation") is null
Source File: /wp-content/themes/twentytwelve/js/navigation.js?ver=1.0
Line: 7

Can a check be added into the Twenty Twelve theme to make sure #site-navigation exists on the page?

Change History (6)

comment:1 @SergeyBiryukov2 years ago

  • Component changed from Themes to Bundled Theme
  • Milestone changed from Awaiting Review to 3.5

comment:2 @DrewAPicture2 years ago

  • Summary changed from Javascript error in 2012 theme if not using nav to Twenty Twelve: Javascript error if not using nav

comment:3 @lancewillett2 years ago

  • Keywords needs-testing added

Hi sswells -- could you please tell us:

  1. Your browser and OS version
  2. What version of Twenty Twelve

The navigation JS file already has a check in place, so it'd be good to try and repeat this with your exact setup.

comment:4 @sswells2 years ago

  1. I'm using FireFox on Mac OS X Lion
  2. Twenty Twelve is Version 1.0. These are the only two instances of 'site-navigation' I can find in the theme.

(twentytwelve/js/navigation.js)

var button = document.getElementById( 'site-navigation' ).getElementsByTagName( 'h3' )[0],

menu = document.getElementById( 'site-navigation' ).getElementsByTagName( 'ul' )[0];

Last edited 2 years ago by sswells (previous) (diff)

comment:5 @lancewillett2 years ago

  • Description modified (diff)
  • Keywords needs-patch added; needs-testing removed
  • Summary changed from Twenty Twelve: Javascript error if not using nav to Twenty Twelve: JavaScript error if not removed navigation wrapper markup

I was able to repeat, but only when removing the entire navigation markup -- not just without a navigation menu since that case was already heavily tested and accounted for.

@lancewillett2 years ago

Note: See TracTickets for help on using tickets.