*Summary:* Arbitrary substitution functions are now defined with "argument grammars" which indicate how they are parsed at parse time, while the function definition specifies the syntax used at substitution/computed value time; see: *var() <https://drafts.csswg.org/css-variables-2/#funcdef-var>*, *env() <https://drafts.csswg.org/css-env-1/#funcdef-env>*, *attr() <https://drafts.csswg.org/css-values-5/#funcdef-attr>*.
Three key changes that this introduces: - Nested references are now possible in the first parameter of these functions, like *var(attr(data-theme-prop type(<custom-ident>)))* and *env(var(--safe-area-block-start))*. These are resolved at substitution time. - Substitution functions that were previously invalid at parse time (like *var(1px)*) are now considered *valid* so long as they match the argument grammar. Parsing into the function's syntax occurs at substitution time (at which point, *var(1px)* would cause the property to be invalid). - Cycles are only evaluated through used arguments. Unused arguments like unused fallbacks in var()/env()/attr(), unvisited branches in if(), or the non-selected options in random-item() are not checked for cycles. This functionality will ship for *var()*/*env()*/*attr()* in Firefox 161 on all platforms, and will provide a foundation for future arbitrary substitution functions. This is not implemented in Blink and is partially implemented in WebKit; see the WPT section below which shows current status. *Bug:* Bug 2080511 - [css-values] Implement argument grammar for var()/env()/attr() arbitrary substitution functions <https://bugzilla.mozilla.org/show_bug.cgi?id=2080511> *Specification:* https://drafts.csswg.org/css-values-5/#substitution *Standards Body:* CSSWG / W3C *Platform Coverage:* All *Preference:* N/A *DevTools Bug:* https://bugzilla.mozilla.org/show_bug.cgi?id=2087964 *Extensions Bug:* N/A *Use Counter:* N/A *Standards-Positions Discussion:* (none found) *web-platform-tests:* See the full set of WPT cases that were modified or added in the implementation patch <https://phabricator.services.mozilla.com/D333056>. Tests are spread across many files, so the *wpt.fyi* links below collect each suite: - var() <https://wpt.fyi/results/css/css-variables?label=master&label=experimental&aligned&q=path%3A%2Fcss%2Fcss-conditional%2Fcontainer-queries%2Fstyle-query-custom-attr-braces-change.html%20or%20path%3A%2Fcss%2Fcss-conditional%2Fcontainer-queries%2Fstyle-query-custom-attr-nested-name-change.html%20or%20path%3A%2Fcss%2Fcss-env%2Fenv-fallback-braces.html%20or%20path%3A%2Fcss%2Fcss-env%2Fenv-fallback-substitution.html%20or%20path%3A%2Fcss%2Fcss-env%2Fenv-parsing.html%20or%20path%3A%2Fcss%2Fcss-env%2Findexed-env.tentative.html%20or%20path%3A%2Fcss%2Fcss-env%2Findexed-env.tentative.html%20or%20path%3A%2Fcss%2Fcss-env%2Fsyntax.tentative.html%20or%20path%3A%2Fcss%2Fcss-values%2Fattr-all-types.html%20or%20path%3A%2Fcss%2Fcss-values%2Fattr-argument-grammar.html%20or%20path%3A%2Fcss%2Fcss-values%2Fattr-fallback-braces.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvar-fallback-braces.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvar-ident-function.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvar-parsing.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvariable-declaration-29.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvariable-reference-name-substitution-attr-taint.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvariable-reference-name-substitution.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvariable-reference.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvariable-supports-30.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvariable-supports-64.html>: Existing argument grammar tests. Passing in Firefox and Safari (since Safari Technology Preview 251 <https://github.com/WebKit/WebKit/commit/8ce7ca092057b07052d0c88e5e3e940970cc75d3> ). - attr() <https://wpt.fyi/results/css/css-values?label=experimental&label=master&aligned&q=path%3A%2Fcss%2Fcss-conditional%2Fcontainer-queries%2Fstyle-query-custom-attr-braces-change.html%20or%20path%3A%2Fcss%2Fcss-conditional%2Fcontainer-queries%2Fstyle-query-custom-attr-nested-name-change.html%20or%20path%3A%2Fcss%2Fcss-env%2Fenv-fallback-braces.html%20or%20path%3A%2Fcss%2Fcss-env%2Fenv-fallback-substitution.html%20or%20path%3A%2Fcss%2Fcss-env%2Fenv-parsing.html%20or%20path%3A%2Fcss%2Fcss-env%2Findexed-env.tentative.html%20or%20path%3A%2Fcss%2Fcss-env%2Findexed-env.tentative.html%20or%20path%3A%2Fcss%2Fcss-env%2Fsyntax.tentative.html%20or%20path%3A%2Fcss%2Fcss-values%2Fattr-all-types.html%20or%20path%3A%2Fcss%2Fcss-values%2Fattr-argument-grammar.html%20or%20path%3A%2Fcss%2Fcss-values%2Fattr-fallback-braces.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvar-fallback-braces.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvar-ident-function.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvar-parsing.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvariable-declaration-29.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvariable-reference-name-substitution-attr-taint.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvariable-reference-name-substitution.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvariable-reference.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvariable-supports-30.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvariable-supports-64.html>: Existing argument grammar tests. Passing in Firefox and Safari (since Safari Technology Preview 241 <https://github.com/WebKit/WebKit/commit/9208303fc946c2789e84139920e390bdacc31901> ) - env() <https://wpt.fyi/results/css/css-env?label=master&label=experimental&aligned&q=path%3A%2Fcss%2Fcss-conditional%2Fcontainer-queries%2Fstyle-query-custom-attr-braces-change.html%20or%20path%3A%2Fcss%2Fcss-conditional%2Fcontainer-queries%2Fstyle-query-custom-attr-nested-name-change.html%20or%20path%3A%2Fcss%2Fcss-env%2Fenv-fallback-braces.html%20or%20path%3A%2Fcss%2Fcss-env%2Fenv-fallback-substitution.html%20or%20path%3A%2Fcss%2Fcss-env%2Fenv-parsing.html%20or%20path%3A%2Fcss%2Fcss-env%2Findexed-env.tentative.html%20or%20path%3A%2Fcss%2Fcss-env%2Findexed-env.tentative.html%20or%20path%3A%2Fcss%2Fcss-env%2Fsyntax.tentative.html%20or%20path%3A%2Fcss%2Fcss-values%2Fattr-all-types.html%20or%20path%3A%2Fcss%2Fcss-values%2Fattr-argument-grammar.html%20or%20path%3A%2Fcss%2Fcss-values%2Fattr-fallback-braces.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvar-fallback-braces.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvar-ident-function.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvar-parsing.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvariable-declaration-29.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvariable-reference-name-substitution-attr-taint.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvariable-reference-name-substitution.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvariable-reference.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvariable-supports-30.html%20or%20path%3A%2Fcss%2Fcss-variables%2Fvariable-supports-64.html>: Updated to add argument grammar tests. Passing in Firefox only (Note: WPT has not been updated upstream yet, see cases in patch). -- You received this message because you are subscribed to the Google Groups "[email protected]" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/a/mozilla.org/d/msgid/dev-platform/94c59c77-a18b-4b31-9aa7-df7cc888bd5fn%40mozilla.org.
