Bug Tracker

Ticket #5543 (closed bug: invalid)

Opened 5 years ago

Last modified 3 years ago

Pseudoelements :last-of-type and :first-of-type broken in certain contexts.

Reported by: Emmett Owned by: john
Priority: minor Milestone: 1.4
Component: selector Version: 1.3.2
Keywords: psuedoelement Cc:
Blocking: Blocked by:

Description

With markup:

<table id="mytable">
    <tbody>
        <tr class="one">
            <td></td>
        </tr>
        <tr class="two">
            <td></td>
        </tr>
    </tbody>
</table>

This works properly:

$("#mytable tbody > tr:last-of-type");  // [ tr.two ]

But this will return all the tr nodes:

$("tbody >tr:last-of-type", "#mytable"); // [ tr.one, tr.two ]

So will this:

$("#mytable tbody").children("tr:last-of-type"); // [ tr.one, tr.two ]

:last-child works in all of these cases.

:first-of-type exhibits the exact same broken behaviour.

Change History

comment:1 Changed 5 years ago by pbcomm

There is no selector :last-of-type, it's :last or :first

comment:2 Changed 4 years ago by dmethvin

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

jQuery doesn't support a :last-of-type selector across browsers, it's not in the API documentation. The selector may work if the browser supports querySelectorAll but it's not in Sizzle.

comment:3 Changed 3 years ago by anonymous

Actually, Resig removed support for this along with a host of other selectors that *were* in jQuery in the past. I don't know why people with bug-moderation privileges wouldn't know about this.

Note: See TracTickets for help on using tickets.