RESOLVED DUPLICATE of bug 206654 198204
:matches() shouldn't allow pseudo-elements inside.
https://bugs.webkit.org/show_bug.cgi?id=198204
Summary :matches() shouldn't allow pseudo-elements inside.
Emilio Cobos Álvarez (:emilio)
Reported 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>
Attachments
Emilio Cobos Álvarez (:emilio)
Comment 1 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.
Ryosuke Niwa
Comment 2 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.
Ryosuke Niwa
Comment 3 2019-05-23 19:04:06 PDT
I think we'd be okay with disallowing this. WDYT, Simon / Dean?
Devin Rousso
Comment 4 2019-05-23 19:17:37 PDT
What about situations like `:matches(::before, ::after)`? For complex selectors, this can "save" a lot of characters.
Antti Koivisto
Comment 5 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.
Antti Koivisto
Comment 6 2020-01-24 00:03:52 PST
*** This bug has been marked as a duplicate of bug 206654 ***
Note You need to log in before you can comment on or make changes to this bug.