Skip to main content

Bug Tracker

Side navigation

#14986 closed bug (wontfix)

Opened April 10, 2014 11:22PM UTC

Closed April 14, 2014 04:53PM UTC

Error when an event is bound to DOMNodeRemoved with an attribute selector and a comment node is removed

Reported by: me@juretriglav.si Owned by:
Priority: low Milestone: None
Component: event Version: 2.1.0
Keywords: Cc:
Blocked by: Blocking:
Description

Came across this while using Foundation 5 tooltips, which binds some things to DOMNodeRemoved: https://github.com/zurb/foundation/blob/master/js/foundation/foundation.tooltip.js#L86-L88

Because the elements are additionally filtered with an attribute selector, jQuery tries to use Sizzle to select the appropriate elements, but because some of the things removed are comment nodes, which have no getAttribute method, it fails.

Example here:

http://jsfiddle.net/L8W7H/

I fixed this in Sizzle, https://github.com/jquery/sizzle/pull/256 but it really seems like it is a jQuery issue, given that Sizzle is supposed to be passed element nodes only.

So I fixed in jQuery too, I'm opening this issue so I can get an issue number to use in the pull request.

Attachments (0)
Change History (2)

Changed April 10, 2014 11:37PM UTC by me@juretriglav.si comment:1

Changed April 14, 2014 04:53PM UTC by dmethvin comment:2

component: unfiledevent
priority: undecidedlow
resolution: → wontfix
status: newclosed

There's a proposed fix in the PR that can be used externally. jQuery shouldn't have text or comment nodes flowing through its event interface. If you're looking to clean up after elements that are being manipulated by jQuery, you could hook jQuery.cleanData or use some other method. See #12213 for ideas.