mirror of
https://github.com/danog/dart-sass.git
synced 2024-11-26 20:24:42 +01:00
Fix variables.
This commit is contained in:
parent
86fa4cf068
commit
b88d0158ec
@ -14,7 +14,9 @@ class Environment {
|
||||
_variables[_variableIndices[name] ?? 0][name];
|
||||
|
||||
void setVariable(String name, Value value, {bool global}) {
|
||||
var index = global ? 0 : _variableIndices[name] ?? _variables.length - 1;
|
||||
var index = global || _variables.length == 1
|
||||
? 0
|
||||
: _variableIndices.putIfAbsent(name, () => _variables.length - 1);
|
||||
_variables[index][name] = value;
|
||||
}
|
||||
|
||||
@ -24,7 +26,9 @@ class Environment {
|
||||
try {
|
||||
return callback();
|
||||
} finally {
|
||||
_variables.removeLast();
|
||||
for (var name in _variables.removeLast().keys) {
|
||||
_variableIndices.remove(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,8 +36,9 @@ class Parser {
|
||||
Stylesheet parse() {
|
||||
var start = _scanner.state;
|
||||
var children = <Statement>[];
|
||||
do {
|
||||
while (true) {
|
||||
children.addAll(_comments());
|
||||
if (_scanner.isDone) break;
|
||||
switch (_scanner.peekChar()) {
|
||||
case $dollar:
|
||||
children.add(_variableDeclaration());
|
||||
@ -47,13 +48,15 @@ class Parser {
|
||||
children.add(_atRule());
|
||||
break;
|
||||
|
||||
case $semicolon: break;
|
||||
case $semicolon:
|
||||
_scanner.readChar();
|
||||
break;
|
||||
|
||||
default:
|
||||
children.add(_styleRule());
|
||||
break;
|
||||
}
|
||||
} while (_scanChar($semicolon));
|
||||
}
|
||||
|
||||
_scanner.expectDone();
|
||||
return new Stylesheet(children, span: _scanner.spanFrom(start));
|
||||
|
Loading…
Reference in New Issue
Block a user