Skip to content

Commit

Permalink
feat: support full css4 logical combination (#2684)
Browse files Browse the repository at this point in the history
  • Loading branch information
iChenLei committed May 26, 2022
1 parent 2bf86ff commit 6a1fb55
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
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

0 comments on commit 6a1fb55

Please sign in to comment.