Bug 198204 - :matches() shouldn't allow pseudo-elements inside.
Summary: :matches() shouldn't allow pseudo-elements inside.
Status: RESOLVED DUPLICATE of bug 206654
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-23 18:27 PDT by Emilio Cobos Álvarez (:emilio)
Modified: 2020-01-24 00:03 PST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Emilio Cobos Álvarez (:emilio) 2019-05-23 18:27:35 PDT
Bug 198147 introduced a check for sub-selectors to know the property whitelist to apply.

I think the right fix is not to parse :matches(::before) to begin with. It just doesn't really make much sense that webkit parses stuff like `:matches(::before):matches(::before)::before`. 

Other pseudo-classes like :host() or pseudo-elements like :host-context() don't allow pseudo-elements in the grammar for this very same reason.

Also, in case you disagree, the check introduced in that bug wouldn't produce the correct behavior, I bet (haven't built myself) that that patch would stop the background / width / etc. from applying to the <li> element in the following test-case:

<!doctype html>
<style>
  :matches(::marker, li) {
    width: 100px;
    height: 100px;
    background: green;
  }
</style>
<li>foo</li>
Comment 1 Emilio Cobos Álvarez (:emilio) 2019-05-23 18:37:26 PDT
Well, I dug through the spec and the spec technically allows (but does not define of course) this grammar.

WebKit is also incompatible with other engines for stuff like :host and such. I filed https://github.com/w3c/csswg-drafts/issues/3963.
Comment 2 Ryosuke Niwa 2019-05-23 19:03:16 PDT
This would have prevented bugs like https://bugs.webkit.org/show_bug.cgi?id=198147 in the first place too.
Comment 3 Ryosuke Niwa 2019-05-23 19:04:06 PDT
I think we'd be okay with disallowing this.

WDYT, Simon / Dean?
Comment 4 Devin Rousso 2019-05-23 19:17:37 PDT
What about situations like `:matches(::before, ::after)`?  For complex selectors, this can "save" a lot of characters.
Comment 5 Antti Koivisto 2019-05-23 19:21:36 PDT
> :matches(::marker, li) {

I'm aware of this, it didn't seem something that would matter in practice.

There is definitely no need to allow :matches(::marker), not sure about other cases.
Comment 6 Antti Koivisto 2020-01-24 00:03:52 PST

*** This bug has been marked as a duplicate of bug 206654 ***