Skip to content

Commit bb510f8

Browse files
committed
More attribute parsing hacking.
1 parent 23a1298 commit bb510f8

2 files changed

Lines changed: 107 additions & 84 deletions

File tree

css3-values/Overview.html

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,55 +1674,57 @@ <h3 id=attr-notation><span class=secno>8.3. </span> Attribute References:
16741674
</div>
16751675

16761676
<p> If the specified attribute exists on the element, the value of the
1677-
attribute must be trimmed of leading and trailing white space and then
1678-
parsed against the <code>any</code> production in the Core Grammar defined
1679-
by CSS 2.1 <a href="#CSS21" rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a>
1680-
If it is successfully parsed as required by the
1681-
<var>&lt;type-or-unit></var> argument (as defined in the list below), the
1682-
resulting value is the attr() expression's value. Otherwise, the attr()
1683-
expression's value is its fallback value.
1677+
attribute must be parsed as required by the <var>&lt;type-or-unit></var>
1678+
argument (as defined in the list below). Unless the type is &lsquo;<code
1679+
class=css>string</code>&rsquo;, it must first be stripped of leading and
1680+
trailing white space. The resulting value is the attr() expression's
1681+
value. If the value did not parse as required, the attr() expression's
1682+
value is its fallback value.
16841683

16851684
<p>The <var>&lt;type-or-unit></var> keywords are:
16861685

16871686
<dl>
16881687
<dt>&lsquo;<code class=css>string</code>&rsquo;
16891688

1690-
<dd>The attribute value will be parsed as the contents of a CSS
1689+
<dd> The attribute value will be parsed as the contents of a CSS
16911690
<var>&lt;string></var>. The default is the empty string.
16921691

16931692
<dt>&lsquo;<code class=css>color</code>&rsquo;
16941693

1695-
<dd>The attribute value will be parsed as a CSS <var>&lt;color></var>
1696-
value. The default is &lsquo;<code class=css>currentColor</code>&rsquo;.
1694+
<dd> The attribute value must parse as a HASH or IDENT CSS token, and be
1695+
successfully interpreted as a <var>&lt;color></var>. The default is
1696+
&lsquo;<code class=css>currentColor</code>&rsquo;.
16971697

16981698
<dt>&lsquo;<a href="#url"><code class=css>url</code></a>&rsquo;
16991699

1700-
<dd>The attribute value will be parsed as the argument of a &lsquo;<a
1701-
href="#url"><code class=css>url()</code></a>&rsquo; expression. The
1702-
default is a UA-dependent URI defined to point to a non-existent document
1703-
with a generic error condition. (i.e. it shouldn't be an FTP URI that
1704-
causes a DNS error, or an HTTP URI that results in a 404, it should be a
1705-
nondescript error condition.) Relative URLs must be made absolute
1700+
<dd> The attribute value will be parsed as the contents of a CSS
1701+
<var>&lt;string></var>. It is interpreted as a quoted string within the
1702+
&lsquo;<a href="#url"><code class=css>url()</code></a>&rsquo; notation.
1703+
The default is a UA-dependent URI defined to point to a non-existent
1704+
document with a generic error condition. (i.e. it shouldn't be an FTP URI
1705+
that causes a DNS error, or an HTTP URI that results in a 404, it should
1706+
be a nondescript error condition.) Relative URLs must be made absolute
17061707
according to the rules of the document language as applied to URLs
17071708
originating from the element; they are not relative to the style sheet.
17081709

17091710
<dt>&lsquo;<a href="#integer"><code class=css>integer</code></a>&rsquo;
17101711

1711-
<dd>The attribute value will be parsed as a CSS <var>&lt;integer></var>.
1712-
The default is &lsquo;<code class=css>0</code>&rsquo;, or else the
1713-
property's minimum value if &lsquo;<code class=css>0</code>&rsquo; is not
1714-
valid for the property. The default should also be used if the property
1715-
in question only accepts integers within a certain range and the
1716-
attribute is out of range.
1712+
<dd> The attribute value must parse as a NUMBER CSS token, and be
1713+
successfully interpreted as an <var>&lt;integer></var>. The default is
1714+
&lsquo;<code class=css>0</code>&rsquo;, or else the property's minimum
1715+
value if &lsquo;<code class=css>0</code>&rsquo; is not valid for the
1716+
property. The default must also be used if the property in question only
1717+
accepts integers within a certain range and the attribute is out of
1718+
range.
17171719

17181720
<dt>&lsquo;<a href="#number"><code class=css>number</code></a>&rsquo;
17191721

1720-
<dd>The attribute value will be parsed as a CSS <var>&lt;number></var>.
1721-
The default is &lsquo;<code class=css>0.0</code>&rsquo;, or else the
1722-
property's minimum value if &lsquo;<code class=css>0.0</code>&rsquo; is
1723-
not valid for the property. The default should also be used if the
1724-
property in question only accepts numbers within a certain range and the
1725-
attribute is out of range.
1722+
<dd> The attribute value must parse as a NUMBER CSS token, and is
1723+
interpreted as an <var>&lt;number></var>. The default is &lsquo;<code
1724+
class=css>0</code>&rsquo;, or else the property's minimum value if
1725+
&lsquo;<code class=css>0</code>&rsquo; is not valid for the property. The
1726+
default must also be used if the property in question only accepts
1727+
integers within a certain range and the attribute is out of range.
17261728

17271729
<dt>&lsquo;<code class=css>length</code>&rsquo;
17281730

@@ -1732,17 +1734,15 @@ <h3 id=attr-notation><span class=secno>8.3. </span> Attribute References:
17321734

17331735
<dt>&lsquo;<code class=css>frequency</code>&rsquo;
17341736

1735-
<dd>The attribute value will be parsed as a CSS <var>&lt;length></var>,
1736-
<var>&lt;angle></var>, <var>&lt;time></var> or <var>&lt;frequency></var>
1737-
(respectively), and the unit identifier (if any) will appear in the
1738-
attribute value. The default is &lsquo;<code class=css>0</code>&rsquo; in
1739-
the relevant units, or else the property's minimum value if &lsquo;<code
1740-
class=css>0</code>&rsquo; in the relevant units is not valid for the
1741-
property. The default should also be used if the property in question
1742-
only accepts values within a certain range (e.g. positive lengths or
1743-
angles from 0 to 90deg) and the attribute is out of range (e.g. a
1744-
negative length or 180deg). If the unit is a relative length, it must be
1745-
computed to an absolute length.
1737+
<dd> The attribute value must parse as a DIMENSION CSS token, and be
1738+
successfully interpreted as the specified type. The default is
1739+
&lsquo;<code class=css>0</code>&rsquo; in the relevant units, or else the
1740+
property's minimum value if &lsquo;<code class=css>0</code>&rsquo; in the
1741+
relevant units is not valid for the property. The default must also be
1742+
used if the property in question only accepts values within a certain
1743+
range (e.g. positive lengths or angles from 0 to 90deg) and the attribute
1744+
is out of range (e.g. a negative length or 180deg). If the unit is a
1745+
relative length, it must be computed to an absolute length.
17461746

17471747
<dt>&lsquo;<a href="#em-unit"><code class=css>em</code></a>&rsquo;
17481748

@@ -1784,12 +1784,15 @@ <h3 id=attr-notation><span class=secno>8.3. </span> Attribute References:
17841784

17851785
<dt>&lsquo;<code class=css>%</code>&rsquo;
17861786

1787-
<dd>The attribute value will be parsed as a CSS <var>&lt;number></var>,
1788-
with the given type suffixed as a unit to create a dimension with the
1789-
given unit's type. The default is &lsquo;<code class=css>0</code>&rsquo;
1790-
in the relevant units, or else the property's minimum value if
1791-
&lsquo;<code class=css>0</code>&rsquo; in the relevant units is not valid
1792-
for the property. If the unit is a relative length, it must be computed
1787+
<dd> The attribute value must parse as a NUMBER CSS token, and is
1788+
interpreted as a <a href="#dimension"><i>dimension</i></a> with the
1789+
specified unit. The default is &lsquo;<code class=css>0</code>&rsquo; in
1790+
the relevant units, or else the property's minimum value if &lsquo;<code
1791+
class=css>0</code>&rsquo; in the relevant units is not valid for the
1792+
property. The default must also be used if the property in question only
1793+
accepts values within a certain range (e.g. positive lengths or angles
1794+
from 0 to 90deg) and the attribute is out of range (e.g. a negative
1795+
length or 180deg). If the unit is a relative length, it must be computed
17931796
to an absolute length.
17941797
</dl>
17951798

css3-values/Overview.src.html

Lines changed: 59 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,59 +1193,72 @@ <h3 id="attr-notation">
11931193

11941194
<p>
11951195
If the specified attribute exists on the element,
1196-
the value of the attribute must be trimmed of leading and trailing white space
1197-
and then parsed against the <code>any</code> production
1198-
in the Core Grammar defined by CSS 2.1 [[!CSS21]]
1199-
If it is successfully parsed as required by the <var>&lt;type-or-unit></var> argument
1200-
(as defined in the list below),
1201-
the resulting value is the attr() expression's value.
1202-
Otherwise, the attr() expression's value is its fallback value.
1196+
the value of the attribute must be parsed as required by the <var>&lt;type-or-unit></var> argument
1197+
(as defined in the list below).
1198+
Unless the type is ''string'', it must first be stripped of leading and trailing white space.
1199+
The resulting value is the attr() expression's value.
1200+
If the value did not parse as required,
1201+
the attr() expression's value is its fallback value.
12031202

12041203
<p>The <var>&lt;type-or-unit></var> keywords are:</p>
12051204

12061205
<dl>
12071206
<dt>''string''
1208-
<dd>The attribute value will be parsed as the contents of a CSS
1209-
<var>&lt;string></var>. The default is the empty string.
1207+
<dd>
1208+
The attribute value will be parsed as the contents of a CSS <var>&lt;string></var>.
1209+
The default is the empty string.
12101210

12111211
<dt>''color''
1212-
<dd>The attribute value will be parsed as a CSS <var>&lt;color></var> value.
1213-
The default is ''currentColor''.
1212+
<dd>
1213+
The attribute value must parse as a HASH or IDENT CSS token,
1214+
and be successfully interpreted as a <var>&lt;color></var>.
1215+
The default is ''currentColor''.
12141216

12151217
<dt>''url''
1216-
<dd>The attribute value will be parsed as the argument of a
1217-
''url()'' expression. The default is a UA-dependent URI defined
1218-
to point to a non-existent document with a generic error
1219-
condition. (i.e. it shouldn't be an FTP URI that causes a DNS
1220-
error, or an HTTP URI that results in a 404, it should be a
1221-
nondescript error condition.) Relative URLs must be made absolute
1222-
according to the rules of the document language as applied to URLs
1223-
originating from the element; they are not relative to the style sheet.
1218+
<dd>
1219+
The attribute value will be parsed as the contents of a CSS <var>&lt;string></var>.
1220+
It is interpreted as a quoted string within the ''url()'' notation.
1221+
The default is a UA-dependent URI defined to point
1222+
to a non-existent document with a generic error condition.
1223+
(i.e. it shouldn't be an FTP URI that causes a DNS error, or an HTTP URI that results in a 404, it should be a nondescript error condition.)
1224+
Relative URLs must be made absolute
1225+
according to the rules of the document language as applied to URLs originating from the element;
1226+
they are not relative to the style sheet.
12241227

12251228
<dt>''integer''
1226-
<dd>The attribute value will be parsed as a CSS <var>&lt;integer></var>.
1227-
The default is ''0'', or else the property's minimum value if ''0'' is not valid for the property. The default should also be used if the property
1228-
in question only accepts integers within a certain range and
1229-
the attribute is out of range.
1229+
<dd>
1230+
The attribute value must parse as a NUMBER CSS token,
1231+
and be successfully interpreted as an <var>&lt;integer></var>.
1232+
The default is ''0'',
1233+
or else the property's minimum value if ''0'' is not valid for the property.
1234+
The default must also be used
1235+
if the property in question only accepts integers within a certain range
1236+
and the attribute is out of range.
12301237

12311238
<dt>''number''
1232-
<dd>The attribute value will be parsed as a CSS <var>&lt;number></var>.
1233-
The default is ''0.0'', or else the property's minimum value if ''0.0'' is not valid for the property. The default should also be used if the
1234-
property in question only accepts numbers within a certain
1235-
range and the attribute is out of range.
1239+
<dd>
1240+
The attribute value must parse as a NUMBER CSS token,
1241+
and is interpreted as an <var>&lt;number></var>.
1242+
The default is ''0'',
1243+
or else the property's minimum value if ''0'' is not valid for the property.
1244+
The default must also be used
1245+
if the property in question only accepts integers within a certain range
1246+
and the attribute is out of range.
12361247

12371248
<dt>''length''
12381249
<dt>''angle''
12391250
<dt>''time''
12401251
<dt>''frequency''
1241-
<dd>The attribute value will be parsed as a CSS <var>&lt;length></var>,
1242-
<var>&lt;angle></var>, <var>&lt;time></var> or <var>&lt;frequency></var> (respectively), and
1243-
the unit identifier (if any) will appear in the attribute value.
1244-
The default is ''0'' in the relevant units, or else the property's minimum value if ''0'' in the relevant units is not valid for the property. The default should also be
1245-
used if the property in question only accepts values within a certain
1246-
range (e.g. positive lengths or angles from 0 to 90deg) and the
1247-
attribute is out of range (e.g. a negative length or 180deg).
1248-
If the unit is a relative length, it must be computed to an absolute length.
1252+
<dd>
1253+
The attribute value must parse as a DIMENSION CSS token,
1254+
and be successfully interpreted as the specified type.
1255+
The default is ''0'' in the relevant units,
1256+
or else the property's minimum value if ''0'' in the relevant units is not valid for the property.
1257+
The default must also be used
1258+
if the property in question only accepts values within a certain range
1259+
(e.g. positive lengths or angles from 0 to 90deg)
1260+
and the attribute is out of range (e.g. a negative length or 180deg).
1261+
If the unit is a relative length, it must be computed to an absolute length.
12491262

12501263
<dt>''em''
12511264
<dt>''ex''
@@ -1267,10 +1280,17 @@ <h3 id="attr-notation">
12671280
<dt>''Hz''
12681281
<dt>''kHz''
12691282
<dt>''%''
1270-
<dd>The attribute value will be parsed as a CSS <var>&lt;number></var>, with the given
1271-
type suffixed as a unit to create a dimension with the given unit's type. The default is ''0'' in the relevant
1272-
units, or else the property's minimum value if ''0'' in the relevant units is not valid for the property.
1273-
If the unit is a relative length, it must be computed to an absolute length.
1283+
<dd>
1284+
The attribute value must parse as a NUMBER CSS token,
1285+
and is interpreted as a <i>dimension</i> with the specified unit.
1286+
The default is ''0'' in the relevant units,
1287+
or else the property's minimum value if ''0'' in the relevant units is not valid for the property.
1288+
The default must also be used
1289+
if the property in question only accepts values within a certain range
1290+
(e.g. positive lengths or angles from 0 to 90deg)
1291+
and the attribute is out of range (e.g. a negative length or 180deg).
1292+
If the unit is a relative length,
1293+
it must be computed to an absolute length.
12741294
</dl>
12751295

12761296
<div class="example">

0 commit comments

Comments
 (0)