Skip to content

[css-mixins] Add CSS Functions and Mixins specification #10367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Resolve to the default value when the type is wrong.
  • Loading branch information
andruud committed May 27, 2024
commit 8fdd46e52826eda14be3c8332a270f4e78d3289c
64 changes: 40 additions & 24 deletions css-mixins-1/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -226,27 +226,21 @@ described in [[!css-variables]].
the |dashed function|'s name as a [=tree-scoped reference=].
If no such name exists, return failure.
2. Let |dependency values| be an initially empty [=list=].
2. For each |dependency| in |function|'s [=function dependency|dependencies=]:
3. For each |dependency| in |function|'s [=function dependency|dependencies=]:
* Let |dependency value| be the value that would be substituted
if a ''var()'' function had been specified explicitly
at the end of |dashed function|'s argument list,
with |dependency| as its only argument.
* If that substitution would have made a containing declaration
[=invalid at computed-value time=],
set |dependency value| to the [=guaranteed-invalid value=].
* If |dependency value| is the [=guaranteed-invalid value=],
and |dependency| has a [=default value=],
set |dependency value| to that [=default value=].
* If |dependency| has a [=parameter type|type=],
set |dependency value| to the result of
[=resolve a typed value|resolving a typed value=],
using |dependency value| as the value,
and the [=syntax definition=] associated with the dependency's type as the syntax.
* Append |dependency value| to |dependency values|.
1. [=Evaluate a custom function=],
* Append the result of [=resolving an argument=] to |dependency values|,
using |dependency value| as value,
and |dependency| as parameter.
4. [=Evaluate a custom function=],
using |function|, |dashed function| and |dependency values|.
2. If failure was returned, return failure.
3. Otherwise,
5. If failure was returned, return failure.
6. Otherwise,
replace the <<dashed-function>> with the [=equivalent token sequence=]
of the value resulting from the evaluation.
</div>
Expand All @@ -273,28 +267,50 @@ Evaluating Custom Functions {#evaluating-custom-functions}
at the same index:
* If |argument| does not exist,
set |argument| to the [=guaranteed-invalid value=].
* If |argument| is the [=guaranteed-invalid value=],
and |parameter| has a [=default value=],
set |argument| to that [=default value=].
* If |parameter| has a [=parameter type|type=],
set |argument| to the result of
[=resolve a typed value|resolving a typed value=],
using |argument| as the |value|,
and the [=syntax definition=] associated with the parameter's type as the |syntax|.
* Replace the value in |dashed function|'s argument list with |argument|.
* Replace the value in |dashed function|'s argument list
with the result of [=resolving an argument=],
using |argument| as value,
and |parameter| as parameter.
3. Let |result| be the [=resolved local value=]
of the '@function/result' descriptor,
using |function|, |dashed function|, and |dependency values|.
4. If |function| has a [=return type=],
set |result| to the result of [=resolve a typed value|resolving a typed value=],
using |result| as the |value|,
and the [=syntax definition=] associated with the [=return type=] as the |syntax|.
using |result| as the value,
and the [=syntax definition=] associated with the [=return type=] as the syntax.
5. If |result| is the [=guaranteed-invalid value=],
return failure.
6. Otherwise,
return |result|.
</div>

<div algorithm>
To <dfn>resolve an argument</dfn>,
with value |value|,
and [=function parameter|parameter=] |parameter|:

1. If |value| is not the [=guaranteed-invalid value=],
and |parameter| has a [=parameter type|type=],
set |value| to the result of [=resolve a typed value|resolving a typed value=]
using |value| as the value,
and the [=syntax definition=] associated with |parameter|'s type as the syntax.
<span class=note>This step may cause |value| to become [=guaranteed-invalid value|guaranteed-invalid=].</span>
2. If |value| is the [=guaranteed-invalid value=],
and |parameter| has a [=default value=],
set |value| to one of the following:
<dl class="switch">
: If |parameter| has a [=parameter type|type=]
:: The result of [=resolve a typed value|resolving a typed value=]
using the |parameter|'s [=default value=] as the value,
and the [=syntax definition=] associated with |parameter|'s type as the syntax.

: Otherwise
:: The |parameter|'s [=default value=].
</dl>
3. Return |value|.

</div>

<div algorithm>
To <dfn>resolve a typed value</dfn>,
with value |value|,
Expand Down