Skip to content

Commit

Permalink
Fix handling of @charset in media imports (#453)
Browse files Browse the repository at this point in the history
Fixes #448
  • Loading branch information
RyanZim committed Mar 31, 2021
1 parent 8b239c6 commit f85d645
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -68,7 +68,7 @@ function AtImport(options) {

function applyMedia(bundle) {
bundle.forEach(stmt => {
if (!stmt.media.length) return
if (!stmt.media.length || stmt.type === "charset") return
if (stmt.type === "import") {
stmt.node.params = `${stmt.fullUri} ${stmt.media.join(", ")}`
} else if (stmt.type === "media")
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/imports/charset-content.css
@@ -0,0 +1,2 @@
@charset "UTF-8";
.charset-content {}
1 change: 1 addition & 0 deletions test/fixtures/media-charset.css
@@ -0,0 +1 @@
@import "charset-content" level-1;
4 changes: 4 additions & 0 deletions test/fixtures/media-charset.expected.css
@@ -0,0 +1,4 @@
@charset "UTF-8";
@media level-1{
.charset-content {}
}
6 changes: 6 additions & 0 deletions test/media.js
Expand Up @@ -19,4 +19,10 @@ test(
"media-content"
)

test(
"should resolve media query imports with charset",
checkFixture,
"media-charset"
)

test("should join correctly media queries", checkFixture, "media-join")

0 comments on commit f85d645

Please sign in to comment.