Skip to content

Commit

Permalink
preserve space before non-parenthesized media query expression - fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Aug 13, 2017
1 parent dff1cb5 commit 9d8f4d3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/css/Stylesheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ class Atrule {

minify(code: MagicString, cascade: boolean) {
if (this.node.name === 'media') {
let c = this.node.start + 6;
const expressionChar = code.original[this.node.expression.start];
let c = this.node.start + (expressionChar === '(' ? 6 : 7);
if (this.node.expression.start > c) code.remove(c, this.node.expression.start);

this.node.expression.children.forEach((query: Node) => {
Expand Down
1 change: 1 addition & 0 deletions test/css/samples/media-query-word/expected.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@media only screen and (min-width: 400px){[svelte-xyz].large-screen,[svelte-xyz] .large-screen{display:block}}
9 changes: 9 additions & 0 deletions test/css/samples/media-query-word/input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class='large-screen'>animated</div>

<style>
@media only screen and (min-width: 400px) {
.large-screen {
display: block;
}
}
</style>

0 comments on commit 9d8f4d3

Please sign in to comment.