Skip to content

Commit

Permalink
ensure that media params remain string values
Browse files Browse the repository at this point in the history
  • Loading branch information
romainmenke committed Feb 9, 2024
1 parent d8a9f21 commit 62dae71
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 21 deletions.
16 changes: 1 addition & 15 deletions lib/parse-statements.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,6 @@ const valueParser = require("postcss-value-parser")
// extended tooling
const { stringify } = valueParser

function split(params, start) {
const list = []
const last = params.reduce((item, node, index) => {
if (index < start) return ""
if (node.type === "div" && node.value === ",") {
list.push(item)
return ""
}
return item + stringify(node)
}, "")
list.push(last)
return list
}

module.exports = function parseStatements(result, styles, conditions, from) {
const statements = []
let nodes = []
Expand Down Expand Up @@ -223,7 +209,7 @@ function parseImport(result, atRule, conditions, from) {
continue
}

media = split(params, i)
media = stringify(params.slice(i))
break
}

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/filter-all.expected.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
@import url("foobar.css");
@import url("foobar.css") screen and (min-width: 25em);
@import url('foobarbaz.css');
@import url('foobarbaz.css') print,screen and (min-width: 25em);
@import url('foobarbaz.css') print, screen and (min-width: 25em);
content{}
2 changes: 1 addition & 1 deletion test/fixtures/filter-some.expected.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ baz{}
baz{}
}
foobarbaz{}
@media print,screen and (min-width: 25em){
@media print, screen and (min-width: 25em){
foobarbaz{}
}
content{}
4 changes: 2 additions & 2 deletions test/fixtures/ignore.expected.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
@import url(//css);
@import "http://css" layer;
@import "http://css" layer(bar);
@import "http://css" layer screen and (min-width: 25em),print;
@import "http://css" layer(bar) screen and (min-width: 25em),print;
@import "http://css" layer screen and (min-width: 25em), print;
@import "http://css" layer(bar) screen and (min-width: 25em), print;
@media (min-width: 25em){
ignore{}
}
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/media-combine.expected.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@media and-left-2 and and-right-2 {}
}

@media or-left-1,or-right-1 {
@media or-left-1, or-right-1 {

@media one-2 {}

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/simple.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
@import url("foobar.css");
@import url("foobar.css") screen and (min-width: 25em);
@import url('foobarbaz.css');
@import url('foobarbaz.css') print, screen and (min-width: 25em);
@import url('foobarbaz.css') print,screen and (min-width: 25em);

content{}

0 comments on commit 62dae71

Please sign in to comment.