Skip to content

Commit 1a7ca79

Browse files
authored
[css-cascade-5] Add the revert-rule keyword (#12992)
A link-defaults entry is needed for 'if()' to avoid links to css-conditional-values-1.
1 parent d6bcca1 commit 1a7ca79

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

css-cascade-5/Overview.bs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Informative Classes: ex
3131
spec:dom; type:dfn; text:shadow tree
3232
spec:css-color-4; type:property; text:color
3333
spec:css-values-3; type: value; text:ex
34+
spec:css-values-5; type: function; text:if()
3435
spec:css-conditional-3; type:at-rule; text:@media
3536
spec:mediaqueries-4; type:type; for:@media; text:all
3637
spec:mediaqueries-4; type:type; text:<media-query>
@@ -1817,7 +1818,7 @@ Explicit Defaulting</h3>
18171818
As specified in <a href="https://www.w3.org/TR/css-values/#common-keywords">CSS Values and Units</a> [[!css-values-3]],
18181819
all CSS properties can accept these values.
18191820

1820-
The keywords ''revert'' and ''revert-layer''
1821+
The keywords ''revert'', ''revert-layer'', and ''revert-rule''
18211822
are <dfn export lt="cascade-dependent keyword">cascade-dependent keywords</dfn>;
18221823
some contexts may restrict their use
18231824
while allowing the other [=CSS-wide keywords=].
@@ -1954,6 +1955,42 @@ Rolling Back Cascade Layers: the ''revert-layer'' keyword</h4>
19541955
as it is for ''revert'',
19551956
and thus effectively forms its own [=cascade layer=].
19561957

1958+
<h4 id="revert-rule-keyword">
1959+
Rolling Back Rules: the ''revert-rule'' keyword</h4>
1960+
1961+
The <dfn value for=all>revert-rule</dfn> [=CSS-wide keyword=]
1962+
rolls back the cascade similar to ''revert'' and ''revert-layer'',
1963+
except it works by [=style rule=]
1964+
rather than [=cascade origin=] or [=cascade layer=].
1965+
1966+
If the <a>cascaded value</a> of a property is the ''revert-rule'' keyword,
1967+
the <a>cascaded value</a> is rolled back
1968+
such that the <a>specified value</a> is calculated
1969+
as if the current [=style rule=] had not been present at all.
1970+
1971+
<div class="example">
1972+
The ''revert-rule'' keyword can be combined with ''if()''
1973+
to conditionally ignore a declaration:
1974+
1975+
<pre class='lang-css'>
1976+
div {
1977+
border-radius: 5px;
1978+
}
1979+
.apply-sharp {
1980+
border-radius: if(style(--mode:sharp): 0px; else: revert-rule);
1981+
}
1982+
</pre>
1983+
1984+
Given an element <code>&lt;div class=apply-sharp></code>,
1985+
the above style sets ''border-radius'' to <code>0px</code>
1986+
only when the [=computed value=] of <code>--mode</code>
1987+
is <code>sharp</code>.
1988+
</pre>
1989+
</div>
1990+
1991+
The ''revert-rule'' keyword behaves like ''revert-layer''
1992+
in the [=author origin=].
1993+
19571994
<h2 id="layer-apis">Layer APIs</h2>
19581995

19591996
<h3 id="the-csslayerblockrule-interface">
@@ -2025,6 +2062,8 @@ Changes since the 13 Jan 2022 Candidate Recommendation Snapshot</h3>
20252062
Non-trivial changes since the <a href="CSS Cascading and Inheritance Level 5">13 January 2022 Candidate Recommendation Snapshot</a>:
20262063

20272064
<!-- to 13 Jan 2022 -->
2065+
* Added the ''revert-rule'' keyword.
2066+
(<a href="https://github.com/w3c/csswg-drafts/issues/10443">Issue 10443</a>)
20282067
* Clarify that all “aliases” of a property are reverted by ''revert''/''revert-layer''.
20292068
* Clarify that style sheets are ordered in [[final CSS style sheets]] order.
20302069
* Clarify that only ''@layer'' statement rules are ignored when checking validity of ''@import'', not empty ''@layer'' block rules.

0 commit comments

Comments
 (0)