Support CSS4 E:nth-child(n of S), E:nth-last-child(n of S)

RESOLVED DUPLICATE of bug 854148

Status

()

Core
CSS Parsing and Computation
RESOLVED DUPLICATE of bug 854148
2 years ago
2 years ago

People

(Reporter: Binyamin, Unassigned)

Tracking

({testcase})

46 Branch
testcase
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

2 years ago
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36

Steps to reproduce:

Testcase https://output.jsbin.com/meliga/quiet


Actual results:

Attribute selector is ignored and :nth-of-type() is applied too all its siblings without the mentioned attribute.
The same result on CSS and JavaScript selector document.querySelectorAll()


Expected results:

See testcase https://output.jsbin.com/meliga/quiet "Expected result".

Did spec ever said anything against to attribute selector behavior for :nth-child(), :nth-last-child(), :nth-of-type() and :nth-last-of-type()?
Spec https://drafts.csswg.org/selectors/#nth-of-type-pseudo
(Reporter)

Updated

2 years ago

Updated

2 years ago
Component: Untriaged → CSS Parsing and Computation
Keywords: testcase
Product: Firefox → Core
The spec you cite clearly says:

  The :nth-of-type(An+B) pseudo-class notation represents the An+Bth element with the
  same namespace and type among its inclusive siblings.

where "type" is a link to https://drafts.csswg.org/selectors/#type-selectors which makes it clear that "type" just means "localName".

So [foo]:nth-of-type(2n) means "Element that has an attribute named 'foo' and which is even-numbered among the set of all its siblings that have the same namespace and localName as itself".  It doesn't matter what the attributes of the other siblings are.

It sounds like you thought "type" meant "things that match the other parts of this selector" or something like that, but that's not what it means in this spec.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → INVALID
(Reporter)

Comment 2

2 years ago
(In reply to Boris Zbarsky [:bz] from comment #1)
> The spec you cite clearly says:
> 
>   The :nth-of-type(An+B) pseudo-class notation represents the An+Bth element
> with the
>   same namespace and type among its inclusive siblings.
> 
> where "type" is a link to https://drafts.csswg.org/selectors/#type-selectors
> which makes it clear that "type" just means "localName".

It means there are no compatible spec-selector for [foo]:nth-of-type(2n) with "things that match the other parts of this selector" and not "type", is it so?
There is a proposal for an :nth-child extension to do that:

  :nth-child(2n of [foo])

It's a pretty recent addition to the (very much not final) spec draft and no one implements yet as far I I'm aware.
(Reporter)

Comment 4

2 years ago
I just updated the title and testcase related to issue (the issue I really meant).
Summary: Attribute selector is ignored for :nth-*() pseudo-classes → Support CSS4 E:nth-child(n of S), E:nth-last-child(n of S)
(Reporter)

Updated

2 years ago
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
Status: UNCONFIRMED → RESOLVED
Last Resolved: 2 years ago2 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 854148
You need to log in before you can comment on or make changes to this bug.