Skip to content

Commit

Permalink
properly ignore embedded imports in data urls
Browse files Browse the repository at this point in the history
  • Loading branch information
romainmenke committed Aug 9, 2023
1 parent a78c387 commit 3449081
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/parse-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ async function resolveImportId(result, stmt, options, state, postcss) {

return
} else if (dataURL.isValid(stmt.from)) {
// Data urls can't be used a base url to resolve imports.
// Data urls can't be used as a base url to resolve imports.
// When the parent statement has a data url
// and the current statement doesn't have a data url we ignore the statement.
// and the current statement doesn't have a data url
// we set the conditions to `not all`.
stmt.media = ["not all"]
return
}

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/data-url.expected.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import url(foo.css);p { color: green; }p { color: blue; }@media (min-width: 320px){@layer foo{
@import url(foo.css) not all;p { color: green; }p { color: blue; }@media (min-width: 320px){@layer foo{
p { color: green; } } }@media (min-width: 320px){@layer foo{

p { color: blue; } } }/* Mixed imports: */p {
Expand Down

0 comments on commit 3449081

Please sign in to comment.