Bug Tracker

Opened 6 years ago

Closed 6 years ago

#14986 closed bug (wontfix)

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

Reported by: me@… 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.

Change History (2)

comment:2 Changed 6 years ago by dmethvin

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.

Note: See TracTickets for help on using tickets.