Skip to content

Commit 91a04cf

Browse files
authored
Merge pull request #1200 from leereamsnyder/process-atsupports
process code in @supports queries with cascade: false
2 parents a49c4fa + cbdbff5 commit 91a04cf

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

src/css/Stylesheet.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class Atrule {
163163
}
164164

165165
apply(node: Element, stack: Element[]) {
166-
if (this.node.name === 'media') {
166+
if (this.node.name === 'media' || this.node.name === 'supports') {
167167
this.children.forEach(child => {
168168
child.apply(node, stack);
169169
});
@@ -199,6 +199,14 @@ class Atrule {
199199
if (this.node.expression.start - c > 1) code.overwrite(c, this.node.expression.start, ' ');
200200
c = this.node.expression.end;
201201
if (this.node.block.start - c > 0) code.remove(c, this.node.block.start);
202+
} else if (this.node.name === 'supports') {
203+
let c = this.node.start + 9;
204+
if (this.node.expression.start - c > 1) code.overwrite(c, this.node.expression.start, ' ');
205+
this.node.expression.children.forEach((query: Node) => {
206+
// TODO minify queries
207+
c = query.end;
208+
});
209+
code.remove(c, this.node.block.start);
202210
}
203211

204212
// TODO other atrules
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
cascade: false
3+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@supports (display: grid){.maybe-grid[svelte-xyz]{display:grid}}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<div class='maybe-grid'>something with a nice layout</div>
2+
3+
<style>
4+
@supports (display: grid) {
5+
.maybe-grid {
6+
display: grid;
7+
}
8+
}
9+
</style>

0 commit comments

Comments
 (0)