Preserve invalid selectors in :is() and :where()#61514
Draft
chromium-wpt-export-bot wants to merge 1 commit into
Draft
Preserve invalid selectors in :is() and :where()#61514chromium-wpt-export-bot wants to merge 1 commit into
chromium-wpt-export-bot wants to merge 1 commit into
Conversation
As per the resolution in w3c/csswg-drafts/issues/8356 [1], forgiving selector lists (argument of :is(), :where()) need to preserve invalid arguments for serialization, even though they never match anything. Use the existing pseudo type kPseudoUnparsed with kNone nesting type to keep an invalid selector text and change the css selector parser so it creates the placeholder for the failed-parsing complex selector. To keep the current First()/Next() behavior of CSSSelectorList, the methods skip the unparsed-invalid selector. FirstIncludingUnparsedInvalid() and NextIncludingUnparsedInvalid() are added in CSSSelectorList to serialize with the unparsed-invalid selectors. Add a private method IsInvalidWithoutUnparsed() to CSSSelectorList to distinguish an empty list (CSSSelectorList::Empty()) from an invalid list that has unparsed-invalid selectors. Replace the IsValid() checks that meant "empty" with it (e.g. in Copy() and ComputeLength()), so the methods can handle the preserved unparsed invalid selectors. The invalid selector serialization works behind the experimental feature SerializeInvalidSelectorsInForgivingSelectorList. [1] w3c/csswg-drafts#8356 Bug: 40277472 Change-Id: I5d350d815153fbf846ed8763707d0938a2327376
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As per the resolution in w3c/csswg-drafts/issues/8356 [1], forgiving
selector lists (argument of :is(), :where()) need to preserve invalid
arguments for serialization, even though they never match anything.
Use the existing pseudo type kPseudoUnparsed with kNone nesting type
to keep an invalid selector text and change the css selector parser
so it creates the placeholder for the failed-parsing complex selector.
To keep the current First()/Next() behavior of CSSSelectorList, the
methods skip the unparsed-invalid selector.
FirstIncludingUnparsedInvalid() and NextIncludingUnparsedInvalid()
are added in CSSSelectorList to serialize with the unparsed-invalid
selectors.
Add a private method IsInvalidWithoutUnparsed() to CSSSelectorList
to distinguish an empty list (CSSSelectorList::Empty()) from an
invalid list that has unparsed-invalid selectors. Replace the IsValid()
checks that meant "empty" with it (e.g. in Copy() and ComputeLength()),
so the methods can handle the preserved unparsed invalid selectors.
The invalid selector serialization works behind the experimental
feature SerializeInvalidSelectorsInForgivingSelectorList.
[1] w3c/csswg-drafts#8356
Bug: 40277472
Change-Id: I5d350d815153fbf846ed8763707d0938a2327376
Reviewed-on: https://chromium-review.googlesource.com/8068106
WPT-Export-Revision: fb02bfdd26247062032ce4291039d902297b9ac4