WordPress.org

Make WordPress Core

Opened 5 months ago

Last modified 5 months ago

#41050 new defect (bug)

Cannot read property 'top' of undefined in belowEntryMetaClass (TwentySeventeen)

Reported by: ericdaams Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.8
Component: Themes Keywords:
Focuses: javascript, template Cc:

Description

I'm seeing this with TwentySeventeen version 1.3 activated:

global.js?ver=1.0:124 Uncaught TypeError: Cannot read property 'top' of undefined
    at belowEntryMetaClass (global.js?ver=1.0:124)
    at global.js?ver=1.0:239

It only occurs in the following circumstance:

  • You have widgets in the sidebar menu.
  • You have a custom template (either defined in your child theme or generated by a plugin) that does not load the sidebar.

If the above are both true, you'll see the error triggered on the window.resize event.

I first encountered this while testing alongside Charitable (create a campaign and then go to donate page), but you can also reproduce by creating a child theme and adding a custom single.php with the sidebar omitted.

Attachments (2)

41050.patch (620 bytes) - added by ericdaams 5 months ago.
41050.2.patch (583 bytes) - added by ericdaams 5 months ago.

Download all attachments as: .zip

Change History (3)

@ericdaams
5 months ago

@ericdaams
5 months ago

#1 @ericdaams
5 months ago

I've added two patches, either of which resolves this. The second is a little more efficient since it only checks $sidebar.length instead of also checking for the has-sidebar body class. My assumption is that if $sidebar.length is false, has-sidebar will never exist as a body class anyway, so it's a redundant check.

Note: See TracTickets for help on using tickets.