Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[selectors] selector list with invalid selector #14442

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ewilligers
Copy link
Contributor

If a selector is invalid, the entire selector list is invalid.
https://drafts.csswg.org/selectors-4/#grouping

If a selector is invalid, the entire selector list is invalid.
https://drafts.csswg.org/selectors-4/#grouping
color: red;
}

.c:is(*, :nonsense) {
Copy link
Contributor

@frivoal frivoal Dec 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on w3c/csswg-drafts#3264 (comment), this one should actually match.

.c:not(*, :nonsense) {
color: red;
}
.c:where(*, :nonsense) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for :is, based on w3c/csswg-drafts#3264 (comment), this one should match.

.c:is(*, :nonsense) {
color: red;
}
.c:not(*, :nonsense) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's remaining discussion in w3c/csswg-drafts#3264 (comment) about what should happen to :not() with invalid arguments. As currently resolved, it should match (so the test would be wrong), but maybe we'll change that, so I would wait for the dust to settle before landing this PR, as this may or may not need fixing.

}

/* Pseudo-elements cannot be represented by the matches-any pseudo-class; they are not valid within :is(). */
.b, :is(::before) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the edits for w3c/csswg-drafts#3264 (comment) haven't been done yet and the discussion is still ongoing, it's not entirely clear what should happen to :is() with a single invalid argument. I would expect that the new invalidation rules would mean that since ::before is not allowed in :is() it gets discarded, but that this merely cause that argument of :is() (in this case its only argument) to be discarded, and the :is() construct as a whole remains valid, even if it matches nothing. So the whole rule is not treated as a syntax error, .b matches, and the element turns red. Which makes the test wrong.

.b, :not(::before) {
color: red;
}
.b, :where(::before) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.b, :is(::before) {
color: red;
}
.b, :not(::before) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort of the same comment as https://github.com/web-platform-tests/wpt/pull/14442/files#r240427239, except that there's still ongoing discussion in that issue about how invalidation of :not() arguments should work. We should wait until the dust settles on that.

Copy link
Contributor

@frivoal frivoal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no inherent dependency on Javascript, so I'd prefer if this was a (series of?) reftests, but that's just a preference, not a show stopper.

Other than that, it seems to me this test is largely incorrect, due to w3c/csswg-drafts#3264 (comment). See individual comments.

@foolip
Copy link
Member

foolip commented Dec 20, 2018

This PR is blocked on the required "Travis CI - Pull Request" check after #14499. In order to trigger it, I will close and reopen this PR.

@foolip foolip closed this Dec 20, 2018
@foolip foolip reopened this Dec 20, 2018
@foolip
Copy link
Member

foolip commented Dec 20, 2018

There's no inherent dependency on Javascript, so I'd prefer if this was a (series of?) reftests, but that's just a preference, not a show stopper.

@frivoal, I just came here to clean up my Travis mess, but am curious about this. Is it not preferable to use CSSOM and things like element.matches to test selectors and style calculation, with reftests used only when the testharness.js variant would be impossible to write, or would effectively be describing "there should be a green box here"? Or are testharness.js tests harder to debug when they fail?

@ewilligers
Copy link
Contributor Author

I was planning to update this test as part of the Blink CL implementing error recovery when the spec updates. I can instead implement that now (without merging into Blink).

I prefer having a dozen asserts to having a dozen reftests or a single reftest with a dozen diffs.
My use of assertions is consistent with https://web-platform-tests.org/writing-tests/index.html

Reftests should be used to test rendering and layout.
testharness.js tests should be used (where possible!) for testing everything else.

@foolip
Copy link
Member

foolip commented Feb 15, 2019

@ewilligers that makes sense to me.

@frivoal
Copy link
Contributor

frivoal commented Oct 1, 2020

Is it not preferable to use CSSOM and things like element.matches to test selectors and style calculation, with reftests used only when the testharness.js variant would be impossible to write, or would effectively be describing "there should be a green box here"?

@foolip Answering this question way late, but given that there exists CSS implementations that do not support JS, it seems better when features that could either be tested in a reftest or in a testharness test are tested in a reftest, without depending on JS. For browsers it doesn't make a difference, but for other implementations it does, and the more common tests we have, the better the interop and the lower the risk of an accidental fork in the platform.

@frivoal
Copy link
Contributor

frivoal commented Oct 1, 2020

Other than that, it seems to me this test is largely incorrect, due to w3c/csswg-drafts#3264 (comment). See individual comments.

@ewilligers Any plan on fixing this (or telling me why I'm wrong), or should we close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants