-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
293 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Built-In Modules | ||
|
||
Sass provides a number of built-in [modules] that may be loaded from URLs with | ||
the scheme `sass`. These modules have no extensions, CSS trees, dependencies, or | ||
source files. Their canonical URLs are the same as the URLs used to load them. | ||
|
||
[modules]: modules.md#module | ||
|
||
## Built-In Functions and Mixins | ||
|
||
Each function and mixin defined in a built-in modules is specified with a | ||
signature of the form | ||
|
||
<x><pre> | ||
[\<ident-token>] ArgumentDeclaration | ||
</pre></x> | ||
|
||
[\<ident-token>]: https://drafts.csswg.org/css-syntax-3/#ident-token-diagram | ||
|
||
followed by a procedure. It's available as a member (either function or mixin) | ||
in the module whose name is the value of the `<ident-token>`. When it's executed | ||
with `args`: | ||
|
||
* With an empty scope with no parent as the [current scope]: | ||
|
||
[current scope]: spec.md#scope | ||
|
||
* Evaluate `args` with the signature's `ArgumentDeclaration`. | ||
|
||
* Run the procedure, and return its result if this is a function. | ||
|
||
Built-in mixins don't accept content blocks unless explicitly specified | ||
otherwise. | ||
|
||
By convention, in these procedures `$var` is used as a shorthand for "the value | ||
of the variable `var` in the current scope". | ||
|
||
> In other words, `$var` is the value passed to the argument `$var`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Functions | ||
|
||
## Table of Contents | ||
|
||
* [Types](#types) | ||
* [Operations](#operations) | ||
* [Equality](#equality) | ||
* [Serialization](#serialization) | ||
|
||
## Types | ||
|
||
The value type known as a "function" is a procedure that takes an | ||
`ArgumentInvocation` `args` and returns a SassScript value. Each function has a | ||
string name. | ||
|
||
> The specific details of executing this procedure differ depending on where and | ||
> how the function is defined. | ||
### Operations | ||
|
||
A function follows the default behavior of all SassScript operations, except | ||
that equality is defined as below. | ||
|
||
#### Equality | ||
|
||
Functions use reference equality: two function values are equal only if they | ||
refer to the exact same instance of the same procedure. | ||
|
||
> If the same file were to be imported multiple times, Sass would create a new | ||
> function value for each `@function` rule each time the file is imported. | ||
> Because a new function value has been created, although the name, body, and | ||
> source span of a given function from the file would be the same between | ||
> imports, the values would not be equal because they refer to different | ||
> instances. Functions pre-defined by the Sass language are instatiated at most | ||
> once during the entire evaluation of a program. | ||
> | ||
> As an example, if we declare two functions: | ||
> | ||
> ```scss | ||
> @function foo() { | ||
> @return red; | ||
> } | ||
> | ||
> $a: meta.get-function(foo); | ||
> | ||
> @mixin foo { | ||
> @return red; | ||
> } | ||
> | ||
> $b: meta.get-mixin(foo); | ||
> ``` | ||
> | ||
> Although every aspect of the two functions is the same, `$a != $b`, because | ||
> they refer to separate function values. | ||
### Serialization | ||
To serialize a function value: | ||
* If the value is not being inspected, throw an error. | ||
* Otherwise, emit `'get-function("'`, then the function's name, then `'")'`. |
Oops, something went wrong.