Opened 9 years ago
Closed 9 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: | 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:1 Changed 9 years ago by
comment:2 Changed 9 years ago by
Component: | unfiled → event |
---|---|
Priority: | undecided → low |
Resolution: | → wontfix |
Status: | new → closed |
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.
Pull request: https://github.com/jquery/jquery/pull/1558