Skip to content

Commit

Permalink
Merge pull request #765 from sveltejs/gh-759
Browse files Browse the repository at this point in the history
preserve space before non-parenthesized media query expression
  • Loading branch information
Rich-Harris authored Aug 13, 2017
2 parents 4aae9a7 + 1f7349c commit 2b41b83
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){div[svelte-xyz],[svelte-xyz] div{color:red}}
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>hello</div>

<style>
@media only screen and (min-width: 400px) {
div {
color: red;
}
}
</style>

0 comments on commit 2b41b83

Please sign in to comment.