Skip to main content

Bug Tracker

Side navigation

#13332 closed bug (fixed)

Opened January 27, 2013 02:04AM UTC

Closed February 13, 2013 02:30AM UTC

Last modified May 24, 2013 01:43PM UTC

.closest("*") yields input even for non-element nodes

Reported by: gibson042 Owned by:
Priority: high Milestone: 1.10/2.0
Component: traversing Version: 1.9.0
Keywords: Cc:
Blocked by: Blocking:

Ref. #13265.

.closest passes text/comment/etc. nodes directly to Sizzle, which assumes all input to be elements, so .closest("*") is erroneously an identity mapping.

Attachments (0)
Change History (6)

Changed February 12, 2013 04:02AM UTC by dmethvin comment:1

Seems like it can easily be fixed, but I suspect it hasn't been reported because it's really rare to get into that situation. For events we make sure the event target is an element, and it would seem really rare for anyone to use .contents() or serialize HTML with top-level text nodes or and then use .closest().

Changed February 12, 2013 05:08AM UTC by gibson042 comment:2

Indeed. This is paired with #13265 in my mind, and they should either fix or wontfix together. A fix looks like

Changed February 13, 2013 02:30AM UTC by Richard Gibson comment:3

resolution: → fixed
status: newclosed

Fix #13265 #13332: Allow .parent/.closest with text nodes. Close gh-1146.

Changeset: 5e29ff7e59a0c97bae02b7512b40486df0f44022

Changed February 13, 2013 02:38AM UTC by dmethvin comment:4

component: unfiledtraversing
milestone: None1.9.2
priority: undecidedhigh

Changed February 13, 2013 03:09AM UTC by Richard Gibson comment:5

Fix #13265 #13332: traversing methods with text nodes. Close gh-1145.

Changeset: b734666f4d2e9a92b8ebb99db5b05bd4c82e71f2

Changed May 24, 2013 01:43PM UTC by dmethvin comment:6


Bulk update to milestone 1.10/2.0