Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added `NestingSelector` node type for `&` (a nesting selector) in selectors - Added `@nest` at-rule - Changed behaviour for `@media` inside a `Rule` to parse its block content as a `Declaration` first - Changed `DeclarationList` behaviour to follow the rules for `Rule`'s block
- Loading branch information
Showing
19 changed files
with
1,420 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"single media type": { | ||
"source": "@nest .bar:not(&) {}", | ||
"generate": "@nest.bar:not(&){}", | ||
"ast": { | ||
"type": "Atrule", | ||
"name": "nest", | ||
"prelude": { | ||
"type": "AtrulePrelude", | ||
"children": [ | ||
{ | ||
"type": "SelectorList", | ||
"children": [ | ||
{ | ||
"type": "Selector", | ||
"children": [ | ||
{ | ||
"type": "ClassSelector", | ||
"name": "bar" | ||
}, | ||
{ | ||
"type": "PseudoClassSelector", | ||
"name": "not", | ||
"children": [ | ||
{ | ||
"type": "SelectorList", | ||
"children": [ | ||
{ | ||
"type": "Selector", | ||
"children": [ | ||
{ | ||
"type": "NestingSelector" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"block": { | ||
"type": "Block", | ||
"children": [] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,261 @@ | ||
{ | ||
"basic": { | ||
"source": " color: blue; &:hover { color: green; } @nest :not(&) { color: red; } ", | ||
"generate": "color:blue;&:hover{color:green}@nest :not(&){color:red}", | ||
"ast": { | ||
"type": "DeclarationList", | ||
"children": [ | ||
{ | ||
"type": "Declaration", | ||
"important": false, | ||
"property": "color", | ||
"value": { | ||
"type": "Value", | ||
"children": [ | ||
{ | ||
"type": "Identifier", | ||
"name": "blue" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Rule", | ||
"prelude": { | ||
"type": "SelectorList", | ||
"children": [ | ||
{ | ||
"type": "Selector", | ||
"children": [ | ||
{ | ||
"type": "NestingSelector" | ||
}, | ||
{ | ||
"type": "PseudoClassSelector", | ||
"name": "hover", | ||
"children": null | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"block": { | ||
"type": "Block", | ||
"children": [ | ||
{ | ||
"type": "Declaration", | ||
"important": false, | ||
"property": "color", | ||
"value": { | ||
"type": "Value", | ||
"children": [ | ||
{ | ||
"type": "Identifier", | ||
"name": "green" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Atrule", | ||
"name": "nest", | ||
"prelude": { | ||
"type": "AtrulePrelude", | ||
"children": [ | ||
{ | ||
"type": "SelectorList", | ||
"children": [ | ||
{ | ||
"type": "Selector", | ||
"children": [ | ||
{ | ||
"type": "PseudoClassSelector", | ||
"name": "not", | ||
"children": [ | ||
{ | ||
"type": "SelectorList", | ||
"children": [ | ||
{ | ||
"type": "Selector", | ||
"children": [ | ||
{ | ||
"type": "NestingSelector" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"block": { | ||
"type": "Block", | ||
"children": [ | ||
{ | ||
"type": "Declaration", | ||
"important": false, | ||
"property": "color", | ||
"value": { | ||
"type": "Value", | ||
"children": [ | ||
{ | ||
"type": "Identifier", | ||
"name": "red" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"nested @media": { | ||
"source": " color: blue; @media (orientation: landscape) { color: red; @media (min-width: 1024px) { color: green; } } ", | ||
"generate": "color:blue;@media (orientation:landscape){color:red;@media (min-width:1024px){color:green}}", | ||
"ast": { | ||
"type": "DeclarationList", | ||
"children": [ | ||
{ | ||
"type": "Declaration", | ||
"important": false, | ||
"property": "color", | ||
"value": { | ||
"type": "Value", | ||
"children": [ | ||
{ | ||
"type": "Identifier", | ||
"name": "blue" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Atrule", | ||
"name": "media", | ||
"prelude": { | ||
"type": "AtrulePrelude", | ||
"children": [ | ||
{ | ||
"type": "MediaQueryList", | ||
"children": [ | ||
{ | ||
"type": "MediaQuery", | ||
"children": [ | ||
{ | ||
"type": "MediaFeature", | ||
"name": "orientation", | ||
"value": { | ||
"type": "Identifier", | ||
"name": "landscape" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"block": { | ||
"type": "Block", | ||
"children": [ | ||
{ | ||
"type": "Declaration", | ||
"important": false, | ||
"property": "color", | ||
"value": { | ||
"type": "Value", | ||
"children": [ | ||
{ | ||
"type": "Identifier", | ||
"name": "red" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Atrule", | ||
"name": "media", | ||
"prelude": { | ||
"type": "AtrulePrelude", | ||
"children": [ | ||
{ | ||
"type": "MediaQueryList", | ||
"children": [ | ||
{ | ||
"type": "MediaQuery", | ||
"children": [ | ||
{ | ||
"type": "MediaFeature", | ||
"name": "min-width", | ||
"value": { | ||
"type": "Dimension", | ||
"value": "1024", | ||
"unit": "px" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"block": { | ||
"type": "Block", | ||
"children": [ | ||
{ | ||
"type": "Declaration", | ||
"important": false, | ||
"property": "color", | ||
"value": { | ||
"type": "Value", | ||
"children": [ | ||
{ | ||
"type": "Identifier", | ||
"name": "green" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"don't parse nested rule when it not started with &": { | ||
"source": ".bar & { color: green; }; div:hover { color: red; }", | ||
"generate": ".bar & { color: green; };div:hover { color: red; }", | ||
"ast": { | ||
|
||
"type": "DeclarationList", | ||
"children": [ | ||
{ | ||
"type": "Raw", | ||
"value": ".bar & { color: green; };" | ||
}, | ||
{ | ||
"type": "Declaration", | ||
"important": false, | ||
"property": "div", | ||
"value": { | ||
"type": "Raw", | ||
"value": "hover { color: red; }" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
Oops, something went wrong.