-
Notifications
You must be signed in to change notification settings - Fork 677
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] consider preserving invalid selectors in :is() and :where() #8356
Comments
If invalid selectors are no longer dropped, |
After the pending test fixes (bug 1843349) we only fail tests due to two reasons: * :has() being unsupported. Not related to the feature itself. * The nesting selector being inside another (invalid) forgiving selector, e.g. :is(!&) not being preserved. The later is pretty much in edge-case-land, and I think w3c/csswg-drafts#8356 would be more consistent rather than doing it only when an & is found (which is very very weird). So I wouldn't want to block on that. Let's let it ride the trains. Differential Revision: https://phabricator.services.mozilla.com/D183519
Yeah I think I'm fine with this. It certainly makes things more consistent, which is nice. |
After the pending test fixes (bug 1843349) we only fail tests due to two reasons: * :has() being unsupported. Not related to the feature itself. * The nesting selector being inside another (invalid) forgiving selector, e.g. :is(!&) not being preserved. The later is pretty much in edge-case-land, and I think w3c/csswg-drafts#8356 would be more consistent rather than doing it only when an & is found (which is very very weird). So I wouldn't want to block on that. Let's let it ride the trains. Differential Revision: https://phabricator.services.mozilla.com/D183519 UltraBlame original commit: 88d3fbc7589e6b57adc0946fe197ada285ac84b7
After the pending test fixes (bug 1843349) we only fail tests due to two reasons: * :has() being unsupported. Not related to the feature itself. * The nesting selector being inside another (invalid) forgiving selector, e.g. :is(!&) not being preserved. The later is pretty much in edge-case-land, and I think w3c/csswg-drafts#8356 would be more consistent rather than doing it only when an & is found (which is very very weird). So I wouldn't want to block on that. Let's let it ride the trains. Differential Revision: https://phabricator.services.mozilla.com/D183519 UltraBlame original commit: 88d3fbc7589e6b57adc0946fe197ada285ac84b7
After the pending test fixes (bug 1843349) we only fail tests due to two reasons: * :has() being unsupported. Not related to the feature itself. * The nesting selector being inside another (invalid) forgiving selector, e.g. :is(!&) not being preserved. The later is pretty much in edge-case-land, and I think w3c/csswg-drafts#8356 would be more consistent rather than doing it only when an & is found (which is very very weird). So I wouldn't want to block on that. Let's let it ride the trains. Differential Revision: https://phabricator.services.mozilla.com/D183519 UltraBlame original commit: 88d3fbc7589e6b57adc0946fe197ada285ac84b7
Preserving invalid/unknown edit: nevermind, this has already been resolved. |
The CSS Working Group just discussed
The full IRC log of that discussion<dbaron> emilio: For nesting, when you have an & in a nested selector, we resolved to preserve the invalid selector inside so that you could properly track whether there was an &. Makes sense. But inconsistent, in the sense that it's a weird special case. Would be more consistent IMO to preserve all invalid selectors. That way you don't special case nesting. It's also more consistent with @supports and @media, with <general-enclosed>.<dbaron> emilio: ... It feels more generally consistent. I don't think it matters particularly... I don't expect compat issues. The question is... as Oriol mentioned, this also makes the empty selector kind of silly. <dbaron> TabAtkins: As a selectors editor, I agree, would be good to keep it ??? defined. <dbaron> TabAtkins: not sure why we decided to drop the invalid selector arguments in :is() <dbaron> emilio: implementation-wise, it's easier to just drop it, but if we need to preserve it, easier to preserve always rather than sometimes. <ntim_> q+ <dbaron> emilio: So if nobody objects I think this would be better than the current specified behavior. <bramus> +1 <Rossen_> ack ntim_ <dbaron> ntim_: Isn't there something about forgiving parsing? <dbaron> emilio: That's the behavior of dropping invalid selector. <dbaron> TabAtkins: nesting cares about whether there's an & at all, so you don't have a newer/older browser behavior switch. <bramus> dbaron: so you would still be treating invalid selectors the same <dbaron> dbaron: ... just preserving them in the OM. <bramus> … but just not drop m <dbaron> TabAtkins: yes <dbaron> emilio: Proposed resolution: preserve invalid selectors inside :is() and :where() regardless of whether there's an & token. <dbaron> ?: do for all forgiving selector lists? <astearns> s/?/matthieudubet <dbaron> TabAtkins: I think that's all of them for now, but we should say for all forgiving selector lists. <dbaron> RESOLVED: preserve invalid selectors inside forgiving selector lists (such as :is() and :where()) regardless of whether there's an & in them |
I think a good reason is that the author can see which selectors are invalid.
Isn't it also easier to serialize all selectors as is? You parse edit: nope, sorry, |
Probably, since the only reasonable use-case for
Not really, because then you need to preserve the specified string. Also it would be a pretty big behavior change (e.g. |
To be clear, I was suggesting to serialize the specified string of all selectors only in On second thought, I also think it is easier to only serialize invalid selectors as-is, which I interpret as with the specified string, rather than the component values. Is it possible to serialize |
Yeah, assuming you're reserializing from the token stream, that's the behavior you'd get by default. There's no whitespace token there, and the two tokens don't need a separator to re-parse successfully. |
Does preserving invalid selectors mean that step 2 will be removed and that items in |
https://bugs.webkit.org/show_bug.cgi?id=258688 rdar://111861948 Reviewed by Antti Koivisto and Darin Adler. For the serialization round-trip to work with the presence of invalid selectors containing a nesting selector, the spec mandates that invalid selectors inside forgiving selector list (such as :is(..) or :where(...)) should be kept in serialization (and be considered when deciding whether a selector is "nest-containing" or not). w3c/csswg-drafts#8356 (comment) * LayoutTests/TestExpectations: * LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/cssom-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/nest-containing-forgiving-expected.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/nest-containing-forgiving-ref.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/nest-containing-forgiving.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/slotted-parsing.html: * LayoutTests/imported/w3c/web-platform-tests/css/selectors/is-where-error-recovery.html: * LayoutTests/imported/w3c/web-platform-tests/css/selectors/is-where-parsing.html: * LayoutTests/imported/w3c/web-platform-tests/css/selectors/parsing/parse-has-disallow-nesting-has-inside-has.html: * LayoutTests/imported/w3c/web-platform-tests/css/selectors/parsing/parse-has.html: * Source/WebCore/css/CSSSelector.cpp: (WebCore::simpleSelectorSpecificity): (WebCore::CSSSelector::selectorText const): (WebCore::CSSSelector::hasExplicitNestingParent const): * Source/WebCore/css/CSSSelector.h: * Source/WebCore/css/SelectorChecker.cpp: (WebCore::canMatchHoverOrActiveInQuirksMode): (WebCore::SelectorChecker::checkOne const): * Source/WebCore/css/parser/CSSSelectorParser.cpp: (WebCore::CSSSelectorParser::consumeForgivingSelectorList): * Source/WebCore/css/parser/CSSSelectorParser.h: * Source/WebCore/cssjit/SelectorCompiler.cpp: (WebCore::SelectorCompiler::constructFragmentsInternal): * Source/WebCore/style/RuleSet.cpp: (WebCore::Style::RuleSet::addRule): * Source/WebCore/style/RuleSetBuilder.cpp: (WebCore::Style::RuleSetBuilder::resolveSelectorListWithNesting): Canonical link: https://commits.webkit.org/266762@main
Neither actually - we need to preserve even things that fail to be a |
As per resolution in w3c/csswg-drafts#8356 Safari already does this. Expand the tests they tweaked to be useful again (test that when non-forgiving parsing is used, then the selector is invalid). Differential Revision: https://phabricator.services.mozilla.com/D189666 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1856018 gecko-commit: 21db15048e15cf9e6583d468f53dcac567c47157 gecko-reviewers: dshin
As per resolution in w3c/csswg-drafts#8356 Safari already does this. Expand the tests they tweaked to be useful again (test that when non-forgiving parsing is used, then the selector is invalid). Differential Revision: https://phabricator.services.mozilla.com/D189666
As per resolution in w3c/csswg-drafts#8356 Safari already does this. Expand the tests they tweaked to be useful again (test that when non-forgiving parsing is used, then the selector is invalid). Differential Revision: https://phabricator.services.mozilla.com/D189666 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1856018 gecko-commit: 2cb6f84a4847fb9df32a8f37fe14deb1ae5602a5 gecko-reviewers: dshin
As per resolution in w3c/csswg-drafts#8356 Safari already does this. Expand the tests they tweaked to be useful again (test that when non-forgiving parsing is used, then the selector is invalid). Differential Revision: https://phabricator.services.mozilla.com/D189666
As per resolution in w3c/csswg-drafts#8356 Safari already does this. Expand the tests they tweaked to be useful again (test that when non-forgiving parsing is used, then the selector is invalid). Differential Revision: https://phabricator.services.mozilla.com/D189666
As per resolution in w3c/csswg-drafts#8356 Safari already does this. Expand the tests they tweaked to be useful again (test that when non-forgiving parsing is used, then the selector is invalid). Differential Revision: https://phabricator.services.mozilla.com/D189666
As per resolution in w3c/csswg-drafts#8356 Safari already does this. Expand the tests they tweaked to be useful again (test that when non-forgiving parsing is used, then the selector is invalid). Differential Revision: https://phabricator.services.mozilla.com/D189666 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1856018 gecko-commit: 2cb6f84a4847fb9df32a8f37fe14deb1ae5602a5 gecko-reviewers: dshin
As per resolution in w3c/csswg-drafts#8356 Safari already does this. Expand the tests they tweaked to be useful again (test that when non-forgiving parsing is used, then the selector is invalid). Differential Revision: https://phabricator.services.mozilla.com/D189666 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1856018 gecko-commit: 2cb6f84a4847fb9df32a8f37fe14deb1ae5602a5 gecko-reviewers: dshin
A few questions that I hope becomes clear when this actually gets a spec: How do these things re-serialize?
|
As per resolution in w3c/csswg-drafts#8356 Safari already does this. Expand the tests they tweaked to be useful again (test that when non-forgiving parsing is used, then the selector is invalid). Differential Revision: https://phabricator.services.mozilla.com/D189666 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1856018 gecko-commit: 2cb6f84a4847fb9df32a8f37fe14deb1ae5602a5 gecko-reviewers: dshin
As per resolution in w3c/csswg-drafts#8356 Safari already does this. Expand the tests they tweaked to be useful again (test that when non-forgiving parsing is used, then the selector is invalid). Differential Revision: https://phabricator.services.mozilla.com/D189666
As per resolution in w3c/csswg-drafts#8356 Safari already does this. Expand the tests they tweaked to be useful again (test that when non-forgiving parsing is used, then the selector is invalid). Differential Revision: https://phabricator.services.mozilla.com/D189666
In #7972 we resolved to preserve invalid selectors that contain an
&
as-is. It seems it'd be more consistent to do that for all invalid:is()
/:where()
branches like:is(:unknown)
. That's how@media
and@supports
behave.The text was updated successfully, but these errors were encountered: