mirror of
https://github.com/danog/dart-sass.git
synced 2025-01-22 05:41:14 +01:00
Fix *-exists(). (#86)
These were always using the global scope rather than the lexical scope. They've been moved into the perform visitor so that they have access to the lexical environment instead.
This commit is contained in:
parent
bf464f0539
commit
63b39479e1
@ -1,5 +1,8 @@
|
||||
## 1.0.0-alpha.7
|
||||
|
||||
* Fix `function-exists()`, `variable-exists()`, and `mixin-exists()` to use the
|
||||
lexical scope rather than always using the global scope.
|
||||
|
||||
* `str-index()` now correctly inserts at negative indices.
|
||||
|
||||
* Properly parse `url()`s that contain comment-like text.
|
||||
|
@ -870,26 +870,11 @@ void defineCoreFunctions(Environment environment) {
|
||||
return new SassBoolean(_features.contains(feature.text));
|
||||
});
|
||||
|
||||
environment.defineFunction("variable-exists", r"$name", (arguments) {
|
||||
var variable = arguments[0].assertString("name");
|
||||
return new SassBoolean(environment.variableExists(variable.text));
|
||||
});
|
||||
|
||||
environment.defineFunction("global-variable-exists", r"$name", (arguments) {
|
||||
var variable = arguments[0].assertString("name");
|
||||
return new SassBoolean(environment.globalVariableExists(variable.text));
|
||||
});
|
||||
|
||||
environment.defineFunction("function-exists", r"$name", (arguments) {
|
||||
var variable = arguments[0].assertString("name");
|
||||
return new SassBoolean(environment.functionExists(variable.text));
|
||||
});
|
||||
|
||||
environment.defineFunction("mixin-exists", r"$name", (arguments) {
|
||||
var variable = arguments[0].assertString("name");
|
||||
return new SassBoolean(environment.mixinExists(variable.text));
|
||||
});
|
||||
|
||||
environment.defineFunction("inspect", r"$value",
|
||||
(arguments) => new SassString(arguments.first.toString()));
|
||||
|
||||
|
@ -128,6 +128,21 @@ class _PerformVisitor
|
||||
: _loadPaths = loadPaths == null ? const [] : new List.from(loadPaths),
|
||||
_environment = environment ?? new Environment(),
|
||||
_color = color {
|
||||
_environment.defineFunction("variable-exists", r"$name", (arguments) {
|
||||
var variable = arguments[0].assertString("name");
|
||||
return new SassBoolean(_environment.variableExists(variable.text));
|
||||
});
|
||||
|
||||
_environment.defineFunction("function-exists", r"$name", (arguments) {
|
||||
var variable = arguments[0].assertString("name");
|
||||
return new SassBoolean(_environment.functionExists(variable.text));
|
||||
});
|
||||
|
||||
_environment.defineFunction("mixin-exists", r"$name", (arguments) {
|
||||
var variable = arguments[0].assertString("name");
|
||||
return new SassBoolean(_environment.mixinExists(variable.text));
|
||||
});
|
||||
|
||||
_environment.defineFunction("call", r"$function, $args...", (arguments) {
|
||||
var function = arguments[0];
|
||||
var args = arguments[1] as SassArgumentList;
|
||||
|
Loading…
x
Reference in New Issue
Block a user