Bug Tracker

Ticket #13332 (closed bug: fixed)

Opened 23 months ago

Last modified 19 months ago

.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:
Blocking: Blocked by:



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.

Change History

comment:1 Changed 23 months ago by dmethvin

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().

comment:2 Changed 23 months ago by gibson042

Indeed. This is paired with #13265 in my mind, and they should either fix or wontfix together. A fix looks like  https://github.com/jquery/jquery/pull/1146.

comment:3 Changed 23 months ago by Richard Gibson

  • Status changed from new to closed
  • Resolution set to fixed

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

Changeset: 5e29ff7e59a0c97bae02b7512b40486df0f44022

comment:4 Changed 23 months ago by dmethvin

  • Priority changed from undecided to high
  • Component changed from unfiled to traversing
  • Milestone changed from None to 1.9.2

comment:5 Changed 23 months ago by Richard Gibson

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

Changeset: b734666f4d2e9a92b8ebb99db5b05bd4c82e71f2

comment:16 Changed 19 months ago by dmethvin

  • Milestone changed from 1.9.2 to 1.10/2.0

Bulk update to milestone 1.10/2.0

Note: See TracTickets for help on using tickets.