Skip to content

Commit 7fa0d2f

Browse files
committed
[css-values-5] Loosen the syntax of attr-unit so unknown units trigger fallback rather than being invalid. #13060
1 parent ca4007d commit 7fa0d2f

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

css-values-5/Overview.bs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,6 +1883,7 @@ Ian's proposal:
18831883
18841884
<dfn>&lt;attr-name></dfn> = [ <<ident-token>>? '|' ]? <<ident-token>>
18851885
<dfn>&lt;attr-type></dfn> = <dfn function lt="type()" for="attr()">type( <<syntax>> )</dfn> | raw-string | number | <<attr-unit>>
1886+
<dfn>&lt;attr-unit></dfn> = <<custom-ident>>
18861887
</pre>
18871888

18881889
The ''attr()'' function's [=argument grammar=] is:
@@ -1898,13 +1899,15 @@ Ian's proposal:
18981899
Note: That is, ''attr(foo)'' does not pass a fallback value,
18991900
but ''attr(foo,)'' does (the fallback is just empty).
19001901

1901-
The <dfn>&lt;attr-unit></dfn> production matches any [=identifier=]
1902+
<<attr-unit>> is intended to represents an [=identifier=]
19021903
that is an [=ASCII case-insensitive=] match
19031904
for the name of a CSS dimension unit,
19041905
such as ''px'',
19051906
or the <<delim-token>> <css>%</css>.
1906-
It is not expanded literally here,
1907-
as the set of units expands over time.
1907+
As this set expands regularly,
1908+
it is actually specified as a <<custom-ident>>,
1909+
and triggers fallback behavior when it doesn't match a known unit
1910+
(rather than making the function invalid).
19081911

19091912
<!-- Switch the <attr-name> to just use <q-name>
19101913
when Namespaces is rewritten
@@ -1957,13 +1960,16 @@ Ian's proposal:
19571960
Values that fail to parse trigger fallback.
19581961

19591962
If given as an <<attr-unit>> value,
1960-
the value is first parsed as if ''number'' keyword was specified,
1961-
then the resulting numeric value
1962-
is turned into a dimension with the corresponding unit,
1963-
or a percentage if <css>%</css> was given.
1964-
Same as for ''number'' <<attr-type>>,
1965-
values that do not correspond to the <<number-token>> production
1966-
trigger fallback.
1963+
the value is first parsed as if ''number'' keyword was specified;
1964+
if this fails to parse,
1965+
it triggers fallback.
1966+
Then, if the <<attr-unit>> value
1967+
matches a known CSS unit name
1968+
or is <css>%</css>,
1969+
the number is turned into a dimension or percentage
1970+
with that value and the given unit.
1971+
If the <<attr-unit>> does not match a known CSS unit,
1972+
it triggers fallback.
19671973

19681974
If given as the <css>raw-string</css> keyword,
19691975
or omitted entirely,
@@ -3081,7 +3087,7 @@ Tree Counting Functions: the ''sibling-count()'' and ''sibling-index()'' notatio
30813087

30823088

30833089
A [=tree-counting function=]
3084-
is a type of [=tree-scoped-reference/loosely-matched=] [=tree-scoped reference=],
3090+
is a type of [=tree-scoped reference/loosely-matched=] [=tree-scoped reference=],
30853091
which is resolved as if the element were given an automatic [=tree-scoped name=]
30863092
that matches an identical automatic name on the [=tree-scoped reference=]
30873093
of the [=tree-counting function=].

0 commit comments

Comments
 (0)