Skip to content
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

feat: support full css level 4 logical combination selectors #2684

Merged
merged 1 commit into from May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/parser.js
Expand Up @@ -66,8 +66,11 @@ var selectorTokens = [
*/

var pseudoSelectors = [
// https://www.w3.org/TR/selectors-4/#logical-combination
// Logical Combinations
'matches'
'is'
, 'has'
, 'where'
, 'not'

// Linguistic Pseudo-classes
Expand Down
29 changes: 29 additions & 0 deletions test/cases/selectors.pseudo.css
Expand Up @@ -94,3 +94,32 @@ label input:blank,
label span {
color: #014;
}
:is(header,
main,
footer) p:hover {
color: #f00;
cursor: pointer;
}
:where(header,
main,
footer) p:hover {
color: #f00;
cursor: pointer;
}
a:where(:not(:hover)) {
text-decoration: none;
}
a:has(> img) {
color: #f00;
}
input {
color: #a7a7a7;
}
input:not(:last-child) {
color: #000;
}
@media (min-width: 0px) {
div :not(.icon) {
display: none;
}
}
20 changes: 20 additions & 0 deletions test/cases/selectors.pseudo.styl
Expand Up @@ -83,3 +83,23 @@ label
input:blank
span
color #014

:is(header, main, footer) p:hover
color: red;
cursor: pointer;
:where(header, main, footer) p:hover
color: red
cursor: pointer
a:where(:not(:hover))
text-decoration: none
a:has(> img)
color: red

input
color #a7a7a7
&:not(:last-child)
color #000

@media (min-width: 0px)
div :not(.icon)
display: none