Bug Tracker

Modify

Ticket #5543 (closed bug: invalid)

Opened 4 years ago

Last modified 2 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 4 years ago by pbcomm

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

comment:2 Changed 3 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 2 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.

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.