Closed Bug 1238864 Opened 8 years ago Closed 8 years ago

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

Categories

(Core :: CSS Parsing and Computation, defect)

46 Branch
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 854148

People

(Reporter: 7raivis, Unassigned)

References

()

Details

(Keywords: testcase)

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
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
Closed: 8 years ago
Resolution: --- → INVALID
(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.
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)
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago8 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.