Skip to main content

Module variables

Module variables 

Source
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
RuleScope
variables of a style rule: the custom properties declared by the rule
VariableEntry
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
VariableScope
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 !important declarations 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 keep is 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 functions is 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. None when 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). None when 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. None when 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 @apply rule belongs to: the declarations of the nearest style rule and of the at-rules between them. None when the @apply rule 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. None when 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