Bug Tracker

Modify

Ticket #13332 (closed bug: fixed)

Opened 4 months ago

Last modified 3 months ago

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

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

Description

 http://jsfiddle.net/xX8F2/

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 3 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 3 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 3 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 3 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 3 months ago by Richard Gibson

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

Changeset: b734666f4d2e9a92b8ebb99db5b05bd4c82e71f2

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.