Skip to content

Commit c223a04

Browse files
committed
Add support for new @supports at-rule.
1 parent 8c17ba1 commit c223a04

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,25 @@ module.exports = function(css){
175175
};
176176
}
177177

178+
/**
179+
* Parse supports.
180+
*/
181+
182+
function supports() {
183+
var m = match(/^@supports *([^{]+)/);
184+
if (!m) return;
185+
var supports = m[1].trim();
186+
187+
if (!open()) return;
188+
comments();
189+
190+
var style = rules();
191+
192+
if (!close()) return;
193+
194+
return { supports: supports, rules: style };
195+
}
196+
178197
/**
179198
* Parse media.
180199
*/
@@ -250,6 +269,7 @@ module.exports = function(css){
250269
function atrule() {
251270
return keyframes()
252271
|| media()
272+
|| supports()
253273
|| atimport()
254274
|| atcharset();
255275
}

test/cases/supports.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@supports (display: flex) or (display: box) {
2+
.flex {
3+
display: box;
4+
display: flex;
5+
}
6+
}

test/cases/supports.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"stylesheet": {
3+
"rules": [
4+
{
5+
"supports": "(display: flex) or (display: box)",
6+
"rules": [
7+
{
8+
"selectors": [
9+
".flex"
10+
],
11+
"declarations": [
12+
{
13+
"property": "display",
14+
"value": "box"
15+
},
16+
{
17+
"property": "display",
18+
"value": "flex"
19+
}
20+
]
21+
}
22+
]
23+
}
24+
]
25+
}
26+
}

0 commit comments

Comments
 (0)