See #3846
2.6 KiB
Declarations
Table of Contents
Syntax
Declaration ::= StandardDeclaration | CustomDeclaration StandardDeclaration ::= InterpolatedIdentifier¹ ':' (Value | Value? '{' Statements '}') CustomDeclaration ::= InterpolatedIdentifier² ':' InterpolatedDeclarationValue
- This may not begin with "--".
- This must begin with "--".
Definitions
Current Declaration Name
The current declaration name is the innermost value declared as such when executing a declaration.
Semantics
To execute a declaration declaration
:
-
Let
parent-name
be the current declaration name, if one exists. -
If
name
is set anddeclaration
is aCustomDeclaration
, throw an error. -
Let
name
be the result of evaluating the all interpolation indeclaration
's name. -
If
parent-name
exists, setname
toparent-name + "-" + name
. -
Declare
name
as the current declaration name for the duration of executingdeclaration
. -
If
declaration
has aValue
:- Let
value
be the result of evaluating thatValue
.
- Let
-
Otherwise, if
declaration
is aCustomDeclaration
:-
Let
value
be an unquoted string whose value is the result of evaluatingdeclaration
'sInterpolatedDeclarationValue
. -
If
value
is empty, throw an error.Note that
value
being only whitespace is allowed, including--foo: ;
.
-
-
Let
parent
be the current style rule, keyframe block, or at-rule; or the innermost if multiple exist.Parsing guarantees that a declaration will have at least one parent.
-
If
value
is set, and it's neither null nor an empty unquoted string:-
Let
css
be a CSS declaration with namename
and valuevalue
. -
Append
css
toparent
. -
If
parent
isn't the last statement in its parent:-
Let
copy
by a copy ofparent
without any children. -
Append
copy
toparent
's parent. -
Set the current style rule, keyframe block, or at-rule (according to
copy
's type) tocopy
, for the remaining duration of its previous value. -
Set
parent
tocopy
.
-
-
-
Evaluate each child in
declaration
'sStatements
if it exists.