Skip to content

Commit b4582b8

Browse files
committed
[css-conditional-5] Extend CSSContainerRule for multiple conditions.
Return an empty string for multiple conditions as per resolution. Fixes #10845
1 parent 3a27bfa commit b4582b8

File tree

1 file changed

+67
-29
lines changed

1 file changed

+67
-29
lines changed

css-conditional-5/Overview.bs

Lines changed: 67 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ Style Container Features</h3>
14641464
The <dfn><<style-feature-name>></dfn> can be either a [=supported CSS property=]
14651465
or a valid <<custom-property-name>>.
14661466
The <dfn><<style-feature-value>></dfn> production matches any valid <<declaration-value>>
1467-
as long as it doesn't contain <<mf-lt>>, <<mf-gt>> and <<mf-eq>> tokens.
1467+
as long as it doesn't contain <<mf-lt>>, <<mf-gt>> and <<mf-eq>> tokens.
14681468

14691469
<wpt>
14701470
container-queries/style-query-registered-custom-rem-change.html
@@ -1970,13 +1970,23 @@ The <code>CSSContainerRule</code> interface</h3>
19701970
The {{CSSContainerRule}} interface represents an ''@container'' rule.
19711971

19721972
<pre class='idl'>
1973+
dictionary CSSContainerCondition {
1974+
required CSSOMString name;
1975+
required CSSOMString query;
1976+
};
1977+
19731978
[Exposed=Window]
19741979
interface CSSContainerRule : CSSConditionRule {
19751980
readonly attribute CSSOMString containerName;
19761981
readonly attribute CSSOMString containerQuery;
1982+
readonly attribute FrozenArray&lt;CSSContainerCondition> conditions;
19771983
};
19781984
</pre>
19791985

1986+
Issue: We should try to remove {{CSSContainerRule/containerName}} and
1987+
{{CSSContainerRule/containerQuery}}, since they don't deal with multiple
1988+
conditions correctly.
1989+
19801990
<wpt>
19811991
container-queries/container-rule-cssom.html
19821992
</wpt>
@@ -1986,39 +1996,67 @@ The <code>CSSContainerRule</code> interface</h3>
19861996
<dd>The <code>conditionText</code> attribute (defined on the <code>CSSConditionRule</code> parent rule),
19871997
on getting, must return a value as follows:
19881998

1989-
<dl class="switch">
1990-
<dt data-md>The ''@container'' rule has an associated <<container-name>>
1991-
<dd data-md>The result of getting the <code>containerName</code> and
1992-
<code>containerQuery</code> attributes, joined by a single whitespace.
1993-
<dt data-md>Otherwise
1994-
<dd data-md>The result of getting the <code>containerQuery</code> attribute.
1995-
</dl>
1999+
<div algorithm="CSSContainerRule.conditionText">
2000+
1. Let |conditions| be the result of getting the {{CSSContainerRule/conditions}} attribute.
2001+
1. Let |first| be <code>true</code>.
2002+
1. Let |result| be the empty string.
2003+
1. [=list/For each=] |condition| in |conditions|:
2004+
1. If |first| is <code>false</code>, append <code>", "</code> to |result|.
2005+
1. Set |first| to <code>false</code>.
2006+
1. If |condition|'s {{CSSContainerCondition/name}} is not empty:
2007+
1. Append |condition|'s {{CSSContainerCondition/name}} to |result|.
2008+
1. If |condition|'s {{CSSContainerCondition/query}} is not empty,
2009+
append a single space to |result|.
2010+
1. Append |condition|'s {{CSSContainerCondition/query}} to |result|.
2011+
1. Return |result|
2012+
</div>
19962013

19972014
<dt><code>containerName</code> of type <code>CSSOMString</code>
19982015
<dd>The <code>containerName</code> attribute, on getting, must return a value as follows:
1999-
2000-
<dl class="switch">
2001-
<dt data-md>The ''@container'' rule has an associated <<container-name>>
2002-
<dd data-md>The result of serializing that <<container-name>>.
2003-
<dt data-md>Otherwise
2004-
<dd data-md>An empty string.
2005-
</dl>
2016+
<div algorithm="CSSContainerRule.containerName">
2017+
1. Let |conditions| be the result of getting the {{CSSContainerRule/conditions}} attribute.
2018+
1. If the length of |conditions| is 1:
2019+
1. Return the only |condition|'s {{CSSContainerCondition/name}}.
2020+
1. return <code>""</code>.
2021+
</div>
20062022

20072023
<dt><code>containerQuery</code> of type <code>CSSOMString</code>
20082024
<dd>The <code>containerQuery</code> attribute,
2009-
on getting, must return the <<container-query>> that was specified,
2010-
without any logical simplifications,
2011-
so that the returned query will evaluate to the same result
2012-
as the specified query
2013-
in any conformant implementation of this specification
2014-
(including implementations that implement future extensions
2015-
allowed by the <<general-enclosed>> extensibility mechanism in this specification).
2016-
In other words,
2017-
token stream simplifications are allowed
2018-
(such as reducing whitespace to a single space
2019-
or omitting it in cases where it is known to be optional),
2020-
but logical simplifications (such as removal of unneeded parentheses,
2021-
or simplification based on evaluating results) are not allowed.
2025+
on getting, must return a value as follows:
2026+
<div algorithm="CSSContainerRule.containerQuery">
2027+
1. Let |conditions| be the result of getting the {{CSSContainerRule/conditions}} attribute.
2028+
1. If the length of |conditions| is 1:
2029+
1. Return the only |condition|'s {{CSSContainerCondition/query}}.
2030+
1. Return <code>""</code>.
2031+
</div>
2032+
2033+
<dt><code>conditions</code> of type <code>FrozenArray&lt;CSSContainerCondition?></code>
2034+
<dd>The <code>conditions</code> attribute, on getting,
2035+
must return a value as follows:
2036+
<div algorithm="CSSContainerRule.conditions">
2037+
1. Let |result| be an empty [=list=].
2038+
1. [=list/For each=] <<container-condition>> |condition| specified in the rule:
2039+
1. Let |dict| be a new {{CSSContainerCondition}} with
2040+
{{CSSContainerCondition/name}} set to the
2041+
<a lt="serialize an identifier">serialized</a> <<container-name>>
2042+
of |condition| if specified, or <code>""</code> otherwise,
2043+
and {{CSSContainerCondition/query}} set to the
2044+
<<container-query>> specified in |condition|
2045+
without any logical simplifications,
2046+
so that the returned query will evaluate to the same result
2047+
as the specified query
2048+
in any conformant implementation of this specification
2049+
(including implementations that implement future extensions
2050+
allowed by the <<general-enclosed>> extensibility mechanism in this specification).
2051+
In other words,
2052+
token stream simplifications are allowed
2053+
(such as reducing whitespace to a single space
2054+
or omitting it in cases where it is known to be optional),
2055+
but logical simplifications (such as removal of unneeded parentheses,
2056+
or simplification based on evaluating results) are not allowed.
2057+
1. [=list/Append=] |dict| to |result|.
2058+
1. Return |result|.
2059+
</div>
20222060
</dl>
20232061

20242062
Issue(6205): Container Queries should have a <code>matchContainer</code> method.
@@ -2116,7 +2154,7 @@ Changes since the <a href="https://www.w3.org/TR/2024/WD-css-conditional-5-20241
21162154
<li>Added axis keywords for overflowing
21172155
(<a href="https://github.com/w3c/csswg-drafts/issues/11183">#11183</a>)
21182156
</li>
2119-
<li>Renamed overflowing to scrollable
2157+
<li>Renamed overflowing to scrollable
21202158
(<a href="https://github.com/w3c/csswg-drafts/issues/11182">#11182</a>)</li>
21212159
<li>Made <<container-query>> optional
21222160
(<a href="https://github.com/w3c/csswg-drafts/issues/9192#issuecomment-1789850349">#9192</a>)

0 commit comments

Comments
 (0)