@@ -7,6 +7,7 @@ import 'package:string_scanner/string_scanner.dart';
7
7
8
8
import '../ast/sass.dart' ;
9
9
import '../functions.dart' ;
10
+ import '../interpolation_buffer.dart' ;
10
11
import 'scss.dart' ;
11
12
12
13
/// The set of all function names disallowed in plain CSS.
@@ -86,16 +87,38 @@ class CssParser extends ScssParser {
86
87
ImportRule _cssImportRule (LineScannerState start) {
87
88
var urlStart = scanner.state;
88
89
var url = switch (scanner.peekChar ()) {
89
- $u || $U => dynamicUrl () as StringExpression ,
90
+ $u || $U => switch (dynamicUrl ()) {
91
+ StringExpression string => string.text,
92
+ InterpolatedFunctionExpression (
93
+ : var name,
94
+ arguments: ArgumentInvocation (
95
+ positional: [StringExpression string],
96
+ named: Map (isEmpty: true ),
97
+ rest: null ,
98
+ keywordRest: null ,
99
+ ),
100
+ : var span
101
+ ) =>
102
+ (InterpolationBuffer ()
103
+ ..addInterpolation (name)
104
+ ..writeCharCode ($lparen)
105
+ ..addInterpolation (string.asInterpolation ())
106
+ ..writeCharCode ($rparen))
107
+ .interpolation (span),
108
+ // This shouldn't be reachable.
109
+ var expression =>
110
+ error ("Unsupported plain CSS import." , expression.span)
111
+ },
90
112
_ => StringExpression (interpolatedString ().asInterpolation (static : true ))
113
+ .text
91
114
};
92
115
93
116
whitespace ();
94
117
var modifiers = tryImportModifiers ();
95
118
expectStatementSeparator ("@import rule" );
96
- return ImportRule ([
97
- StaticImport (url.text , scanner.spanFrom (urlStart), modifiers: modifiers)
98
- ], scanner.spanFrom (start));
119
+ return ImportRule (
120
+ [ StaticImport (url, scanner.spanFrom (urlStart), modifiers: modifiers)],
121
+ scanner.spanFrom (start));
99
122
}
100
123
101
124
ParenthesizedExpression parentheses () {
0 commit comments