Skip to content

Commit 0e6b4ef

Browse files
tursunovatabatkins
andauthored
Add number keyword for attr() and specify how <attr-unit> should be parsed (#12862)
* Add number keyword for attr() and specify how <attr-unit> should be parsed * Update css-values-5/Overview.bs * Update css-values-5/Overview.bs --------- Co-authored-by: Tab Atkins Jr. <[email protected]>
1 parent 2e1871e commit 0e6b4ef

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

css-values-5/Overview.bs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,7 +1867,7 @@ Ian's proposal:
18671867
attr() = attr( <<attr-name>> <<attr-type>>? , <<declaration-value>>?)
18681868
18691869
<dfn>&lt;attr-name></dfn> = [ <<ident-token>>? '|' ]? <<ident-token>>
1870-
<dfn>&lt;attr-type></dfn> = <dfn function lt="type()" for="attr()">type( <<syntax>> )</dfn> | raw-string | <<attr-unit>>
1870+
<dfn>&lt;attr-type></dfn> = <dfn function lt="type()" for="attr()">type( <<syntax>> )</dfn> | raw-string | number | <<attr-unit>>
18711871
</pre>
18721872

18731873
The ''attr()'' function's [=argument grammar=] is:
@@ -1929,12 +1929,19 @@ Ian's proposal:
19291929
Values that fail to parse according to the syntax
19301930
trigger fallback.
19311931

1932+
If given as the <css>number</css> keyword,
1933+
it causes the attribute's literal value,
1934+
after [=strip leading and trailing ASCII whitespace|stripping leading and trailing whitespace=],
1935+
to be [=CSS/parsed=] as a <<number-token>>.
1936+
Values that fail to parse trigger fallback.
1937+
19321938
If given as an <<attr-unit>> value,
1933-
the value is first parsed as if <css>type(&lt;number>)</css> was specified,
1939+
the value is first parsed as if ''number'' keyword was specified,
19341940
then the resulting numeric value
19351941
is turned into a dimension with the corresponding unit,
19361942
or a percentage if <css>%</css> was given.
1937-
Values that fail to parse as a <css>&lt;number></css>
1943+
Same as for ''number'' <<attr-type>>,
1944+
values that do not correspond to the <<number-token>> production
19381945
trigger fallback.
19391946

19401947
If given as the <css>raw-string</css> keyword,
@@ -2040,20 +2047,27 @@ Substitution</h4>
20402047
let |attr value| be its value;
20412048
otherwise jump to the last step (labeled FAILURE).
20422049

2043-
4. If |syntax| is null
2050+
4. If |syntax| is the keyword ''number'' or an <<attr-unit>> value,
2051+
parse |attr value| against <<attr-type>>.
2052+
If that succeeds, return the result;
2053+
otherwise, jump to the last step (labeled FAILURE).
2054+
2055+
Note: No parsing or modification of any kind is performed on the value.
2056+
2057+
5. If |syntax| is null
20442058
or the keyword ''raw-string'',
20452059
return a CSS <<string>>
20462060
whose value is |attr value|.
20472061

20482062
Note: No parsing or modification of any kind is performed on the value.
20492063

2050-
5. [=Substitute arbitrary substitution functions=] in |attr value|,
2064+
6. [=Substitute arbitrary substitution functions=] in |attr value|,
20512065
with &bs<<;"attribute", |attr name|&bs>>; as the [=substitution context=],
20522066
then [=parse with a <syntax>=] |attr value|, with |syntax| and |el|.
20532067
If that succeeds, return the result;
20542068
otherwise, jump to the last step (labeled FAILURE).
20552069

2056-
6. <b>FAILURE:</b>
2070+
7. <b>FAILURE:</b>
20572071

20582072
1. If |second arg| is null,
20592073
and |syntax| was omitted,

0 commit comments

Comments
 (0)