[wp-trac] [WordPress Trac] #44526: Admin Bar: Fail gracefully when adding events to non-existent elements
WordPress Trac
noreply at wordpress.org
Thu Jul 5 23:23:33 UTC 2018
#44526: Admin Bar: Fail gracefully when adding events to non-existent elements
--------------------------+--------------------
Reporter: obenland | Owner: (none)
Type: defect (bug) | Status: new
Priority: low | Milestone: 5.0
Component: Toolbar | Version: 3.1
Severity: minor | Keywords:
Focuses: javascript |
--------------------------+--------------------
When testing if `addEventListener` or `attachEvent` are available for an
object it just checks for it to be truthy
([https://core.trac.wordpress.org/browser/trunk/src/js/_enqueues/lib
/admin-bar.js?rev=43342#L302 source]), which works if it is available, if
it's not it creates a type error:
`TypeError: Cannot read property 'addEventListener' of null`
This can occur in circumstances where jQuery is not available and
plugin/themes remove nodes that `admin-bar.js` expects to be available. To
reproduce install & activate [https://wordpress.org/plugins/logged-out-
admin-bar/ Logged Out Admin Bar] and visit your test site with a theme
enabled that does not use jQuery, like [https://wordpress.org/themes
/responsive-kubrick/ Responsive Kubrick].
While it's technically not a core bug, let's make sure it fails a little
more gracefully when it does encounter these circumstances.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44526>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list