Skip to content

Preserve invalid selectors in :is() and :where()#61514

Draft
chromium-wpt-export-bot wants to merge 1 commit into
masterfrom
chromium-export-cl-8068106
Draft

Preserve invalid selectors in :is() and :where()#61514
chromium-wpt-export-bot wants to merge 1 commit into
masterfrom
chromium-export-cl-8068106

Conversation

@chromium-wpt-export-bot

Copy link
Copy Markdown
Collaborator

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

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

2 participants