@@ -61,13 +61,13 @@ abstract class StylesheetParser extends Parser {
61
61
var _inExpression = false ;
62
62
63
63
/// A map from all variable names that are assigned with `!global` in the
64
- /// current stylesheet to the nodes where they're defined.
64
+ /// current stylesheet to the spans where they're defined.
65
65
///
66
66
/// These are collected at parse time because they affect the variables
67
67
/// exposed by the module generated for this stylesheet, *even if they aren't
68
68
/// evaluated*. This allows us to ensure that the stylesheet always exposes
69
69
/// the same set of variable names no matter how it's evaluated.
70
- final _globalVariables = < String , VariableDeclaration > {};
70
+ final _globalVariables = < String , FileSpan > {};
71
71
72
72
/// Warnings discovered while parsing that should be emitted during
73
73
/// evaluation once a proper logger is available.
@@ -100,15 +100,8 @@ abstract class StylesheetParser extends Parser {
100
100
});
101
101
scanner.expectDone ();
102
102
103
- /// Ensure that all global variable assignments produce a variable in this
104
- /// stylesheet, even if they aren't evaluated. See sass/language#50.
105
- statements.addAll (_globalVariables.values.map ((declaration) =>
106
- VariableDeclaration (declaration.name,
107
- NullExpression (declaration.expression.span), declaration.span,
108
- guarded: true )));
109
-
110
103
return Stylesheet .internal (statements, scanner.spanFrom (start), warnings,
111
- plainCss: plainCss);
104
+ plainCss: plainCss, globalVariables : _globalVariables );
112
105
});
113
106
}
114
107
@@ -288,7 +281,7 @@ abstract class StylesheetParser extends Parser {
288
281
guarded: guarded,
289
282
global: global,
290
283
comment: precedingComment);
291
- if (global) _globalVariables.putIfAbsent (name, () => declaration);
284
+ if (global) _globalVariables.putIfAbsent (name, () => declaration.span );
292
285
return declaration;
293
286
}
294
287
0 commit comments