Bug Tracker

Opened 10 years ago

Closed 10 years ago

#13902 closed bug (wontfix)

parents("table:first tr:first") is not fectching the tr in the thead.

Reported by: [email protected] Owned by:
Priority: high Milestone: 1.10/2.0
Component: selector Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:

Description

<!DOCTYPE html> <html> <head> <script src="ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"> </script> <script> $(document).ready(function(){

alert($("tr:first",$("a.updatelink").parents("table")).length); alert($("a.updatelink").parents("table:first tr:first").length);

}); </script> </head> <body> <table class="basicsorttable" border="1"><thead class="TableSort"><tr><th ColKey="PAYMENT-PaidMode">Pay Type</th><th ColKey="PAYMENT-PaidDate">Date</th><th ColKey="PAYMENT-PaidStatus">Status</th><th ColKey="PAYMENT-PaidCheqNo">CHQ-DD No</th><th ColKey="PAYMENT-PaidBankName">Bank Name</th><th ColKey="PAYMENT-PaidValue">Amount</th><th class="sorttable_nosort">Update</th><th class="sorttable_nosort">Delete</th></tr></thead><tbody><tr id="0"><td>Cash</td><td>08-May-2013</td><td>Paid</td><td></td><td></td><td>150.0</td><td align="center"><a href='#' class='updatelink'hre='191'><img src="/Apps/fwk/img/detail.gif" alt="Detail" border="0"/></a></td><td align="center"><a href='#' onclick="DelConfirm('/Apps/fin/rbl/fin_rbl_overview.jsp?sid=171&ACTION=payment&TBLDELETE=191&')"><img src="/Apps/fwk/img/delete.gif" alt="Delete" border="0"/></a></td></tr></tbody></table> </body> </html>

The First alert shows 1, The second lert also should show 1, however it is showing 0 in 1.9.1. This was working fine in 1.4.4

Change History (3)

comment:1 Changed 10 years ago by dmethvin

Test case with all the bad markup and extraneous stuff removed:

http://jsfiddle.net/YNT73/

It looks to me like 1.9.1 is correct because the first TR in the table is in the THEAD and therefore not a parent of the element.

comment:2 Changed 10 years ago by m_gol

Component: unfiledselector
Milestone: None1.10/2.0
Priority: undecidedhigh

@dmethvin: your test case has jQuery 1.7.2 chosen. Look at:
http://jsfiddle.net/YNT73/3/
y and z should point to the same nodes, shouldn't they? There's only one table in the test after all.

comment:3 Changed 10 years ago by gibson042

Resolution: wontfix
Status: newclosed

Supplying the optional argument to .parents is functionally equivalent to .parents().filter( arg ), and examining the behavior of .filter will show that there's just no reasonable use involving selectors that mix positional and relative components, in part due to conflicting interpretations about what is to be selected: http://jsfiddle.net/YNT73/6/

Please either use CSS selectors like :first-child/:nth-child()/etc. if you can; otherwise substitute a filter function or method chain.

Note: See TracTickets for help on using tickets.