Expand description
Port of src/ast/mixins/variables.ts: the variables of the mixins and of the custom functions. The var()
functions that reference the private variables (mixin arguments, @private, local variables of a custom function,
…) are replaced by a copy of the variable value (https://drafts.csswg.org/css-mixins-1/).
The scopes are trait objects (VariableScope), the variables are shared cells. A variable refers to the scope its
value is resolved in with a weak reference: the scopes own their variables (no reference cycle), the scopes are
alive while their variables are resolved.
Structs§
- Parameter
- mixin or custom function parameter
- Rule
Scope - variables of a style rule: the custom properties declared by the rule
- Variable
Entry - a private variable (
VariableEntry)
Enums§
- Found
- result of
VariableScope::lookup - Substituted
- value of a var() function or of a custom function call
Constants§
- SCOPE_
RULES - at-rules that may contain mixin and custom function definitions
Traits§
- Definition
- a definition located in the tree
- Variable
Scope - variables visible from a value
Functions§
- collect_
at_ rules - the mixin or custom function at-rules of a stylesheet
- collect_
definitions - collect the mixin or custom function definitions of a stylesheet, a conditional group rule or a cascade layer.
the definitions that are not valid are collected in
invalid - collect_
properties - custom properties declared by the children of a node: the
!importantdeclarations override the other declarations, the last declaration wins. the declarations of the inner nodes override the outer nodes - declaration_
value - value tokens of a declaration, without
!important - definition_
name - name of a mixin or a custom function definition:
@mixin --name(...),@function --name(...) - finalize_
definitions - finalize the mixin or custom function definitions once they are evaluated: the evaluated definitions are replaced
with a comment unless
keepis set, the definitions that are kept are reduced to their last definition in the same scope, the definitions that are not valid are left as is - first_
token - first token that is not a whitespace or a comment
- has_
reference - true if a token or one of its descendants is a var() function, or a custom function call when
functionsis set - is_
at_ rule - true if the node is an at-rule with the given name
- is_
blank - true if the token is a whitespace or a comment
- is_
comment - is_
custom_ property - true if the node is a custom property declaration
- is_
scope_ rule - true if the node is an at-rule with a block that may contain mixin definitions
- is_var
- true if the token is a var() function
- matches_
type - true if a value matches the type of a parameter. a value that is resolved by the browser is not checked
- parameter_
syntax - syntax of a parameter type:
<color>-><color>,type(<length> | auto)-><length> | auto.Nonewhen the parameter is not typed or accepts any value - parse_
arguments - arguments of a mixin or a custom function call: the comments and the whitespace are ignored, the curly braces are removed
- parse_
parameters - parse the parameters of a mixin or a custom function:
--name(--a, --b <color>: red).Nonewhen the parameters are not valid - render
- render tokens
- replace_
variables - replace the var() functions that reference a private variable with literal tokens holding the value. false when the value is not valid
- resolve
- resolved value of a variable.
Nonewhen the value is invalid - resolve_
definitions - the definitions visible from a reference: the definitions of the innermost scope that defines the name
- rule_
properties - custom properties of the rule the
@applyrule belongs to: the declarations of the nearest style rule and of the at-rules between them.Nonewhen the@applyrule is not inside a style rule - split_
arguments - split a list of tokens on the commas that are not wrapped in curly braces. the comments are ignored
- substitute
- render tokens, the var() functions that reference a private variable replaced by a copy of the variable value, the
custom function calls replaced by their result when the scope evaluates them.
Nonewhen a variable is invalid and var() has no fallback: the value is not valid - substitute_
variable - value of a var() function
- trim
- remove the leading and trailing whitespace and comments
- unwrap
- remove the curly braces that wrap a comma containing value:
{a, b}->a, b
Type Aliases§
- Entry
- a shared variable
- Properties
- custom properties by name