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