Skip to main content

Bug Tracker

Side navigation

#13902 closed bug (wontfix)

Opened May 17, 2013 11:59AM UTC

Closed May 21, 2013 01:49PM UTC

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

Reported by: prashanthkris@yahoo.com 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

Attachments (0)
Change History (3)

Changed May 17, 2013 01:02PM UTC by dmethvin comment:1

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.

Changed May 20, 2013 06:12PM UTC by m_gol comment:2

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.

Changed May 21, 2013 01:49PM UTC by gibson042 comment:3

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.