Skip to content

Commit 7fa95d8

Browse files
authored
Make DOMTokenList's supported token concept also depend on element
It makes no sense for it to just depend on the attribute name. Also modernize this section while here.
1 parent 91f4611 commit 7fa95d8

File tree

1 file changed

+70
-33
lines changed

1 file changed

+70
-33
lines changed

dom.bs

Lines changed: 70 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10530,72 +10530,89 @@ interface DOMTokenList {
1053010530
<dfn export id=concept-dtl-tokens for=DOMTokenList>token set</dfn> (a <a for=/>set</a>), which is
1053110531
initially empty.
1053210532

10533-
<p>A {{DOMTokenList}} object also has an associated <a for=/>element</a> and an <a>attribute</a>'s
10534-
<a for=Attr>local name</a>.
10533+
<p>A {{DOMTokenList}} object also has an associated <dfn for=DOMTokenList>element</dfn>
10534+
(an <a for=/>element</a>) and an <dfn for=DOMTokenList>attribute name</dfn> (an <a>attribute</a>'s
10535+
<a for=Attr>local name</a>).
1053510536

1053610537
<a lt="Other applicable specifications">Specifications</a> may define
1053710538
<dfn export for=Node id=concept-supported-tokens>supported tokens</dfn> for a {{DOMTokenList}}'s
10538-
associated <a>attribute</a>'s <a for=Attr>local name</a>.
10539+
<a for=DOMTokenList>element</a> and <a for=DOMTokenList>attribute name</a>.
1053910540

10540-
<p>A {{DOMTokenList}} object's
10541+
<div algorithm>
10542+
<p>A {{DOMTokenList}} object <var>set</var>'s
1054110543
<dfn export id=concept-domtokenlist-validation for=DOMTokenList>validation steps</dfn> for a given
1054210544
<var>token</var> are:
1054310545

1054410546
<ol>
10545-
<li><p>If the associated <a>attribute</a>'s <a for=Attr>local name</a> does not define
10546-
<a for=Node>supported tokens</a>, <a>throw</a> a <code>TypeError</code>.
10547+
<li><p>If <var>set</var>'s <a for=DOMTokenList>element</a> and
10548+
<a for=DOMTokenList>attribute name</a> does not define <a for=Node>supported tokens</a>, then
10549+
<a>throw</a> a <code>TypeError</code>.
1054710550

10548-
<li><p>Let <var>lowercase token</var> be a copy of <var>token</var>, in <a>ASCII lowercase</a>.
10551+
<li><p>Let <var>lowercaseToken</var> be <var>token</var>, in <a>ASCII lowercase</a>.
1054910552

10550-
<li><p>If <var>lowercase token</var> is present in <a for=Node>supported tokens</a>, return true.
10553+
<li><p>If <var>lowercaseToken</var> is present in the <a for=Node>supported tokens</a> of
10554+
<var>set</var>'s <a for=DOMTokenList>element</a> and <a for=DOMTokenList>attribute name</a>, then
10555+
return true.
1055110556

1055210557
<li><p>Return false.
1055310558
</ol>
10559+
</div>
1055410560

10555-
<p>A {{DOMTokenList}} object's <dfn id=concept-dtl-update for="DOMTokenList">update steps</dfn> are:
10561+
<div algorithm>
10562+
<p>A {{DOMTokenList}} object <var>set</var>'s
10563+
<dfn id=concept-dtl-update for="DOMTokenList">update steps</dfn> are:
1055610564

1055710565
<ol>
10558-
<li><p>If the associated <a for=/>element</a> does not have an associated <a>attribute</a> and
10559-
<a>token set</a> is empty, then return.
10566+
<li><p>If <a>get an attribute by namespace and local name</a> given null, <var>set</var>'s
10567+
<a for=DOMTokenList>attribute name</a>, and <var>set</var>'s <a for=DOMTokenList>element</a>
10568+
returns null and <var>set</var>'s <a>token set</a> is empty, then return.
1056010569

10561-
<li><p><a>Set an attribute value</a> for the associated <a for=/>element</a> using associated
10562-
<a>attribute</a>'s <a for=Attr>local name</a> and the result of running the <a>ordered set
10563-
serializer</a> for <a>token set</a>.
10570+
<li><p><a>Set an attribute value</a> given <var>set</var>'s <a for=DOMTokenList>element</a>,
10571+
<var>set</var>'s <a for=DOMTokenList>attribute name</a>, and the result of running the
10572+
<a>ordered set serializer</a> for <var>set</var>'s <a>token set</a>.
1056410573
</ol>
10574+
</div>
1056510575

10566-
<p>A {{DOMTokenList}} object's <dfn id=concept-dtl-serialize for=DOMTokenList>serialize steps</dfn>
10567-
are to return the result of running <a>get an attribute value</a> given the associated
10568-
<a for=/>element</a> and the associated <a>attribute</a>'s <a for=Attr>local name</a>.</p>
10576+
<div algorithm>
10577+
<p>A {{DOMTokenList}} object <var>set</var>'s
10578+
<dfn id=concept-dtl-serialize for=DOMTokenList>serialize steps</dfn> are to return the result of
10579+
running <a>get an attribute value</a> given <var>set</var>'s <a for=DOMTokenList>element</a> and
10580+
<var>set</var>'s <a for=DOMTokenList>attribute name</a>.
10581+
</div>
1056910582

1057010583
<hr>
1057110584

10572-
<p>A {{DOMTokenList}} object has these <a>attribute change steps</a> for its associated
10573-
<a for=/>element</a>:
10585+
<div algorithm="DOMTokenList/attribute change steps">
10586+
<p>A {{DOMTokenList}} object <var>set</var> has these <a>attribute change steps</a> for
10587+
<var>set</var>'s <a for=DOMTokenList>element</a>:
1057410588

1057510589
<ol>
10576-
<li><p>If <var>localName</var> is associated attribute's <a for=Attr>local name</a>,
10590+
<li><p>If <var>localName</var> is <var>set</var>'s <a for=DOMTokenList>attribute name</a>,
1057710591
<var>namespace</var> is null, and <var>value</var> is null, then <a for=set>empty</a>
1057810592
<a>token set</a>.
1057910593

10580-
<li><p>Otherwise, if <var>localName</var> is associated attribute's <a for=Attr>local name</a>,
10581-
<var>namespace</var> is null, then set <a>token set</a> to <var>value</var>,
10582-
<a lt="ordered set parser">parsed</a>.
10594+
<li><p>Otherwise, if <var>localName</var> is <var>set</var>'s
10595+
<a for=DOMTokenList>attribute name</a> and <var>namespace</var> is null, then set <var>set</var>'s
10596+
<a>token set</a> to <var>value</var>, <a lt="ordered set parser">parsed</a>.
1058310597
</ol>
10598+
</div>
1058410599

10585-
<p>When a {{DOMTokenList}} object is created, then:
10600+
<div algorithm="DOMTokenList/created">
10601+
<p>When a {{DOMTokenList}} object <var>set</var> is created:
1058610602

1058710603
<ol>
10588-
<li><p>Let <var>element</var> be associated <a for=/>element</a>.
10604+
<li><p>Let <var>element</var> be <var>set</var>'s <a for=DOMTokenList>element</a>.
1058910605

10590-
<li><p>Let <var>localName</var> be associated attribute's <a for=Attr>local name</a>.
10606+
<li><p>Let <var>attributeName</var> be <var>set</var>'s <a for=DOMTokenList>attribute name</a>.
1059110607

1059210608
<li><p>Let <var>value</var> be the result of
1059310609
<a lt="get an attribute value">getting an attribute value</a> given <var>element</var> and
10594-
<var>localName</var>.
10610+
<var>attributeName</var>.
1059510611

10596-
<li><p>Run the <a>attribute change steps</a> for <var>element</var>, <var>localName</var>,
10612+
<li><p>Run the <a>attribute change steps</a> for <var>element</var>, <var>attributeName</var>,
1059710613
<var>value</var>, <var>value</var>, and null.
1059810614
</ol>
10615+
</div>
1059910616

1060010617
<dl class=domintro>
1060110618
<dt><code><var>tokenlist</var> . {{DOMTokenList/length}}</code>
@@ -10656,13 +10673,16 @@ are to return the result of running <a>get an attribute value</a> given the asso
1065610673
<p>Can be set, to change the associated attribute.
1065710674
</dl>
1065810675

10659-
<p>The <dfn attribute for=DOMTokenList><code>length</code></dfn> attribute' getter must return
10676+
<div algorithm>
10677+
<p>The <dfn attribute for=DOMTokenList><code>length</code></dfn> getter steps are to return
1066010678
<a>this</a>'s <a>token set</a>'s <a for=set>size</a>.
10679+
</div>
1066110680

1066210681
<p>The object's <a>supported property indices</a> are the numbers in the range zero to object's
1066310682
<a>token set</a>'s <a for=set>size</a> &minus; 1, unless <a>token set</a> <a for=set>is empty</a>,
1066410683
in which case there are no <a>supported property indices</a>.
1066510684

10685+
<div algorithm>
1066610686
<p>The <dfn method for="DOMTokenList"><code>item(<var>index</var>)</code></dfn> method steps are:
1066710687

1066810688
<ol>
@@ -10671,11 +10691,15 @@ in which case there are no <a>supported property indices</a>.
1067110691

1067210692
<li><p>Return <a>this</a>'s <a>token set</a>[<var>index</var>].
1067310693
</ol>
10694+
</div>
1067410695

10696+
<div algorithm>
1067510697
<p>The <dfn method for="DOMTokenList"><code>contains(<var>token</var>)</code></dfn> method steps are
1067610698
to return true if <a>this</a>'s <a>token set</a>[<var>token</var>] <a for=set>exists</a>; otherwise
1067710699
false.
10700+
</div>
1067810701

10702+
<div algorithm>
1067910703
<p>The
1068010704
<dfn method for="DOMTokenList" lt="add(tokens)|add()"><code>add(<var>tokens</var>&hellip;)</code></dfn>
1068110705
method steps are:
@@ -10697,7 +10721,9 @@ method steps are:
1069710721

1069810722
<li><p>Run the <a>update steps</a>.
1069910723
</ol>
10724+
</div>
1070010725

10726+
<div algorithm>
1070110727
<p>The
1070210728
<dfn method for="DOMTokenList" lt="remove(tokens)|remove()"><code>remove(<var>tokens</var>&hellip;)</code></dfn>
1070310729
method steps are:
@@ -10719,7 +10745,9 @@ method steps are:
1071910745

1072010746
<li><p>Run the <a>update steps</a>.
1072110747
</ol>
10748+
</div>
1072210749

10750+
<div algorithm>
1072310751
<p>The <dfn method for=DOMTokenList><code>toggle(<var>token</var>, <var>force</var>)</code></dfn>
1072410752
method steps are:
1072510753

@@ -10746,10 +10774,12 @@ method steps are:
1074610774

1074710775
<li><p>Return false.
1074810776
</ol>
10777+
</div>
1074910778

1075010779
<p class=note>The <a>update steps</a> are not always run for {{DOMTokenList/toggle()}}
1075110780
for web compatibility.
1075210781

10782+
<div algorithm>
1075310783
<p>The
1075410784
<dfn method for=DOMTokenList><code>replace(<var>token</var>, <var>newToken</var>)</code></dfn>
1075510785
method steps are:
@@ -10772,10 +10802,12 @@ method steps are:
1077210802

1077310803
<li><p>Return true.
1077410804
</ol>
10805+
</div>
1077510806

1077610807
<p class=note>The <a>update steps</a> are not always run for {{DOMTokenList/replace()}}
1077710808
for web compatibility.
1077810809

10810+
<div algorithm>
1077910811
<p>The
1078010812
<dfn method for="DOMTokenList" lt="supports(token)"><code>supports(<var>token</var>)</code></dfn>
1078110813
method steps are:
@@ -10786,13 +10818,18 @@ method steps are:
1078610818

1078710819
<li><p>Return <var>result</var>.
1078810820
</ol>
10821+
</div>
1078910822

10790-
<p>The <dfn attribute for=DOMTokenList><code>value</code></dfn> attribute must return the
10823+
<div algorithm>
10824+
<p>The <dfn attribute for=DOMTokenList><code>value</code></dfn> getter steps are to return the
1079110825
result of running <a>this</a>'s <a>serialize steps</a>.
10826+
</div>
1079210827

10793-
<p>Setting the {{DOMTokenList/value}} attribute must <a>set an attribute value</a> for the
10794-
associated <a for=/>element</a> using associated <a>attribute</a>'s <a for=Attr>local name</a> and
10795-
the given value.
10828+
<div algorithm="DOMTokenList/value setter">
10829+
<p>The <a attribute for=DOMTokenList><code>value</code></a> setter steps are to
10830+
<a>set an attribute value</a> for <a>this</a>'s <a for=DOMTokenList>element</a> using <a>this</a>'s
10831+
<a for=DOMTokenList>attribute name</a> and the given value.
10832+
</div>
1079610833

1079710834

1079810835

0 commit comments

Comments
 (0)