Bug Tracker

Opened 14 years ago

Closed 13 years ago

Last modified 12 years ago

#5543 closed bug (invalid)

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

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

comment:1 Changed 14 years ago by pbcomm

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

comment:2 Changed 13 years ago by dmethvin

Resolution: invalid
Status: newclosed

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 12 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.