Revert "Add built-in variables e and pi. (#907)"

This reverts commit 2cb69e70ab.
This commit is contained in:
Jennifer Thakar 2020-01-02 13:45:49 -08:00
parent 2cb69e70ab
commit 3c64addbf3
3 changed files with 5 additions and 16 deletions

View File

@ -6,8 +6,6 @@
* `hypot()`: given *n* numbers, outputs the length of the *n*-dimensional * `hypot()`: given *n* numbers, outputs the length of the *n*-dimensional
vector that has components equal to each of the inputs. vector that has components equal to each of the inputs.
* Add the variables `$pi` and `$e` to the built-in "sass:math" module.
## 1.24.0 ## 1.24.0
* Add an optional `with` clause to the `@forward` rule. This works like the * Add an optional `with` clause to the `@forward` rule. This works like the

View File

@ -25,10 +25,7 @@ final global = UnmodifiableListView([
final module = BuiltInModule("math", functions: [ final module = BuiltInModule("math", functions: [
_abs, _ceil, _clamp, _compatible, _floor, _hypot, _isUnitless, _max, _min, // _abs, _ceil, _clamp, _compatible, _floor, _hypot, _isUnitless, _max, _min, //
_percentage, _randomFunction, _round, _unit, _percentage, _randomFunction, _round, _unit,
], variables: { ]);
"e": SassNumber(math.e),
"pi": SassNumber(math.pi),
});
/// Returns a [Callable] named [name] that transforms a number's value /// Returns a [Callable] named [name] that transforms a number's value
/// using [transform] and preserves its units. /// using [transform] and preserves its units.

View File

@ -17,22 +17,19 @@ class BuiltInModule<T extends AsyncCallable> implements Module<T> {
final Uri url; final Uri url;
final Map<String, T> functions; final Map<String, T> functions;
final Map<String, T> mixins; final Map<String, T> mixins;
final Map<String, Value> variables;
List<Module<T>> get upstream => const []; List<Module<T>> get upstream => const [];
Map<String, Value> get variables => const {};
Map<String, AstNode> get variableNodes => const {}; Map<String, AstNode> get variableNodes => const {};
Extender get extender => Extender.empty; Extender get extender => Extender.empty;
CssStylesheet get css => CssStylesheet.empty(url: url); CssStylesheet get css => CssStylesheet.empty(url: url);
bool get transitivelyContainsCss => false; bool get transitivelyContainsCss => false;
bool get transitivelyContainsExtensions => false; bool get transitivelyContainsExtensions => false;
BuiltInModule(String name, BuiltInModule(String name, {Iterable<T> functions, Iterable<T> mixins})
{Iterable<T> functions, Iterable<T> mixins, Map<String, Value> variables})
: url = Uri(scheme: "sass", path: name), : url = Uri(scheme: "sass", path: name),
functions = _callableMap(functions), functions = _callableMap(functions),
mixins = _callableMap(mixins), mixins = _callableMap(mixins);
variables =
variables == null ? const {} : UnmodifiableMapView(variables);
/// Returns a map from [callables]' names to their values. /// Returns a map from [callables]' names to their values.
static Map<String, T> _callableMap<T extends AsyncCallable>( static Map<String, T> _callableMap<T extends AsyncCallable>(
@ -43,11 +40,8 @@ class BuiltInModule<T extends AsyncCallable> implements Module<T> {
{for (var callable in callables) callable.name: callable})); {for (var callable in callables) callable.name: callable}));
void setVariable(String name, Value value, AstNode nodeWithSpan) { void setVariable(String name, Value value, AstNode nodeWithSpan) {
if (!variables.containsKey(name)) {
throw SassScriptException("Undefined variable."); throw SassScriptException("Undefined variable.");
} }
throw SassScriptException("Cannot modify built-in variable.");
}
Module<T> cloneCss() => this; Module<T> cloneCss() => this;
} }