Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix @import url("...") in plain CSS #2398

Merged
merged 1 commit into from
Oct 18, 2024
Merged

Fix @import url("...") in plain CSS #2398

merged 1 commit into from
Oct 18, 2024

Conversation

nex3
Copy link
Contributor

@nex3 nex3 commented Oct 18, 2024

@nex3 nex3 requested a review from jathak October 18, 2024 22:57
$u || $U => dynamicUrl() as StringExpression,
$u || $U => switch (dynamicUrl()) {
StringExpression string => string.text,
InterpolatedFunctionExpression(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would work for most of the cases. However, this would attempt to parse a "interpolated" string. In pure css, technically I can do @import url("a.css#{url-with-a-weird-hash}"); and it should still be valid, but I suppose this will throw interpolation is not allowed in css?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other words, strings in plain css should probably never be parsed as interpolated, even if they contain sass interpolation syntax.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code isn't actually parsing anything, it's just handling the various formats that the dynamicUrl() function can return. But yes, interpolations will throw errors in plain CSS mode even when they are technically valid CSS—largely because LibSass incorrectly interpreted .css files as SCSS, so we want to highlight places where that's not working. It might be worth revisiting that decision for Dart Sass 3.0.0, but probably not for 2.0.0.

@nex3 nex3 merged commit 76cfd6b into main Oct 18, 2024
38 checks passed
@nex3 nex3 deleted the import-quoted-url branch October 18, 2024 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

type 'InterpolatedFunctionExpression' is not a subtype of type 'StringExpression'
3 participants