LeaVerou / css3test

How does your browser score for its CSS3 support?
http://css3test.com
MIT License
214 stars 83 forks source link

Validity of :nth-*(-n-1) #22

Closed rasamassen closed 2 years ago

rasamassen commented 12 years ago

According to the spec, there's nothing syntactically wrong with this selector, true.

But the spec also says: The value a can be negative, but only the positive values of an+b, for n≥0, may represent an element in the document tree.

The example that follows is: html|tr:nth-child(-n+6) /* represents the 6 first rows of XHTML tables */

Thus, though the syntax is correct, the selector results in no positive values. Browsers (like Chrome, which currently fails this test) don't need to support input that has no representation in the document tree. I feel this selector test (it happens 4 times in the CSS3Test) should be removed as invalid.

LeaVerou commented 12 years ago

Browsers don't need to support input that has no representation in the document tree.

Is this your personal opinion or part of the spec?

rasamassen commented 12 years ago

The second line is a quote from the spec. Only positive values matter in the document tree.

Personal opinion is I'm not sure what value there is in testing things that have no meaning when parsed. What does it matter for the future of CSS if a browser supports a input that is meaningless? (-n-1) can never result in a positive value and thus, according to the spec, will never affect the document tree. Who really cares if a browser supports it? The test is pointless, even if it is syntactically valid.

LeaVerou commented 12 years ago

Yes, I know that only positive values matter in the document tree. I was asking about the part I quoted.

And yes, values with no representation can often be useful. For example, in feature detection.

deepj commented 10 years ago

I'm in to remove it. At least for me, it doesn't make sense at all even though it's syntactically valid.

SebastianZ commented 2 years ago

The tests for :nth-*(-n-1) selectors got removed now, so closing this issue.

Happy New Year everyone!

Sebastian