Skip to content

Commit 4b291d1

Browse files
committed
Use a single concept for attribute changes
This setup is still a little sketchy I think, but not more so than the insertion and removing steps.
1 parent 36ef32e commit 4b291d1

File tree

2 files changed

+93
-62
lines changed

2 files changed

+93
-62
lines changed

dom.bs

Lines changed: 55 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5573,11 +5573,10 @@ given a <var>document</var>, <var>localName</var>, <var>prefix</var>, <var>names
55735573
<var>A</var> is in its
55745574
<a for=Element>attribute list</a>.
55755575

5576-
This specification uses and
5577-
<a lt="other applicable specifications">applicable specifications</a> can use the hooks an
5578-
<dfn export>attribute is set</dfn>, an <dfn export>attribute is changed</dfn>, an
5579-
<dfn export>attribute is added</dfn>, and an <dfn export>attribute is removed</dfn>, for
5580-
further processing of the <a>attribute</a>'s <a for=Attr>value</a>.
5576+
This and <a lt="other applicable specifications">other specifications</a> may define
5577+
<dfn id=concept-element-attributes-change-ext>attribute change steps</dfn> for
5578+
<a for=/>elements</a>. The algorithm is passed <var>element</var>, <var>localName</var>,
5579+
<var>oldValue</var>, <var>value</var>, and <var>namespace</var>.
55815580

55825581
To <dfn export id=concept-element-attributes-change lt="change an attribute">change</dfn> an
55835582
<a>attribute</a> <var>attribute</var>
@@ -5598,11 +5597,12 @@ to <var>value</var>, run these steps:
55985597
list containing <var>attribute</var>'s <a for=Attr>local name</a>, <var>attribute</var>'s
55995598
<a for=Attr>value</a>, <var>value</var>, and <var>attribute</var>'s <a for=Attr>namespace</a>.
56005599

5600+
<li><p>Run the <a>attribute change steps</a> with <var>element</var>, <var>attribute</var>'s
5601+
<a for=Attr>local name</a>, <var>attribute</var>'s <a for=Attr>value</a>, <var>value</var>, and
5602+
<var>attribute</var>'s <a for=Attr>namespace</a>.
5603+
56015604
<li>Set <var>attribute</var>'s
56025605
<a for=Attr>value</a> to <var>value</var>.
5603-
5604-
<li>An <a>attribute is set</a> and an
5605-
<a>attribute is changed</a>.
56065606
</ol>
56075607

56085608
To <dfn export id=concept-element-attributes-append lt="append an attribute">append</dfn> an
@@ -5623,14 +5623,15 @@ run these steps:
56235623
list containing <var>attribute</var>'s <a for=Attr>local name</a>, null, <var>attribute</var>'s
56245624
<a for=Attr>value</a>, and <var>attribute</var>'s <a for=Attr>namespace</a>.
56255625

5626+
<li><p>Run the <a>attribute change steps</a> with <var>element</var>, <var>attribute</var>'s
5627+
<a for=Attr>local name</a>, null, <var>attribute</var>'s <a for=Attr>value</a>, and
5628+
<var>attribute</var>'s <a for=Attr>namespace</a>.
5629+
56265630
<li>Append the <var>attribute</var> to the <var>element</var>'s
56275631
<a for=Element>attribute list</a>.
56285632

56295633
<li>Set <var>attribute</var>'s
56305634
<a for=Attr>element</a> to <var>element</var>.
5631-
5632-
<li>An <a>attribute is set</a> and an
5633-
<a>attribute is added</a>.
56345635
</ol>
56355636

56365637
To <dfn export id=concept-element-attributes-remove lt="remove an attribute">remove</dfn> an
@@ -5652,14 +5653,16 @@ run these steps:
56525653
list containing <var>attribute</var>'s <a for=Attr>local name</a>, <var>attribute</var>'s
56535654
<a for=Attr>value</a>, null, and <var>attribute</var>'s <a for=Attr>namespace</a>.
56545655

5656+
<li><p>Run the <a>attribute change steps</a> with <var>element</var>, <var>attribute</var>'s
5657+
<a for=Attr>local name</a>, <var>attribute</var>'s <a for=Attr>value</a>, null, and
5658+
<var>attribute</var>'s <a for=Attr>namespace</a>.
5659+
56555660
<li>Remove <var>attribute</var> from the
56565661
<var>element</var>'s
56575662
<a for=Element>attribute list</a>.
56585663

56595664
<li>Set <var>attribute</var>'s
56605665
<a for=Attr>element</a> to null.
5661-
5662-
<li>An <a>attribute is removed</a>.
56635666
</ol>
56645667

56655668
To <dfn export id=concept-element-attributes-replace lt="replace an attribute">replace</dfn> an
@@ -5678,14 +5681,16 @@ in an <a for="/">element</a> <var>element</var>, run these steps:
56785681
<a for=Attr>value</a>, <var>newAttr</var>'s <a for=Attr>value</a>, and <var>oldAttr</var>'s
56795682
<a for=Attr>namespace</a>.
56805683

5684+
<li><p>Run the <a>attribute change steps</a> with <var>element</var>, <var>oldAttr</var>'s
5685+
<a for=Attr>local name</a>, <var>oldAttr</var>'s <a for=Attr>value</a>, <var>newAttr</var>'s
5686+
<a for=Attr>value</a>, and <var>oldAttr</var>'s <a for=Attr>namespace</a>.
5687+
56815688
<li><p>Replace <var>oldAttr</var> by <var>newAttr</var> in the <var>element</var>'s
56825689
<a for=Element>attribute list</a>.
56835690

56845691
<li><p>Set <var>oldAttr</var>'s <a for=Attr>element</a> to null.
56855692

56865693
<li><p>Set <var>newAttr</var>'s <a for=Attr>element</a> to <var>element</var>.
5687-
5688-
<li><p>An <a>attribute is set</a> and an <a>attribute is changed</a>.
56895694
</ol>
56905695

56915696
<hr>
@@ -5825,24 +5830,15 @@ the HTML <code>id</code> <a>attribute</a> and a DTD. This specification makes <a
58255830
concept of the DOM and allows for only one per <a for="/">element</a>, given by an
58265831
<a lt="named attribute"><code>id</code> attribute</a>.
58275832

5828-
When an <a for="/">element</a> is created that
5829-
<a lt="has an attribute">has</a> an
5830-
<a lt="named attribute"><code>id</code> attribute</a> whose
5831-
<a for=Attr>value</a> is not the empty string or
5832-
when an <a for="/">element</a>'s
5833-
<a lt="named attribute"><code>id</code> attribute</a> is
5834-
<a lt="attribute is set">set</a> to a
5835-
<a for=Attr>value</a> other than the empty
5836-
string, set the <a for="/">element</a>'s
5837-
<a>ID</a> to the new
5838-
<a for=Attr>value</a>.
5833+
<p>Use these <a>attribute change steps</a> to update an <a for=/>element</a>'s <a>ID</a>:
58395834

5840-
When an <a for="/">element</a>'s
5841-
<a lt="named attribute"><code>id</code> attribute</a> is
5842-
<a lt="attribute is removed">removed</a> or
5843-
<a lt="attribute is set">set</a> to the empty string, unset the
5844-
<a for="/">element</a>'s
5845-
<a>ID</a>.
5835+
<ol>
5836+
<li><p>If <var>localName</var> is <code>id</code>, <var>namespace</var> is null, and
5837+
<var>value</var> is null or the empty string, then unset <var>element</var>'s <a>ID</a>.
5838+
5839+
<li><p>Otherwise, if <var>localName</var> is <code>id</code>, <var>namespace</var> is null, then
5840+
set <var>element</var>'s <a>ID</a> to <var>value</var>.
5841+
</ol>
58465842

58475843
<p class="note no-backref">While this specification defines requirements for <code>class</code>,
58485844
<code>id</code>, and <code>slot</code> <a>attributes</a> on any <a for="/">element</a>, it makes no
@@ -9203,17 +9199,33 @@ are to return the result of running <a>get an attribute value</a> given the asso
92039199

92049200
<hr>
92059201

9206-
<p>When a {{DOMTokenList}} object is created and its associated <a for="/">element</a>
9207-
<a lt="has an attribute">has</a> an
9208-
<a lt="named attribute"><var>associated attribute's local name</var> attribute</a> or
9209-
associated <a for="/">element</a>'s
9210-
<a lt="named attribute"><var>associated attribute's local name</var> attribute</a> is
9211-
<a lt="attribute is set">set</a>, set <a>tokens</a> to the new <a for=Attr>value</a>,
9212-
<a lt="ordered set parser">parsed</a>.
9213-
9214-
<p>When an associated <a for="/">element</a>'s
9215-
<a lt="named attribute"><var>associated attribute's local name</var> attribute</a> is
9216-
<a lt="attribute is removed">removed</a>, set <a>tokens</a> to the empty set.
9202+
<p>A {{DOMTokenList}} object has these <a>attribute change steps</a> for its associated
9203+
<a for=/>element</a>:
9204+
9205+
<ol>
9206+
<li><p>If <var>localName</var> is associated attribute's <a for=Attr>local name</a>,
9207+
<var>namespace</var> is null, and <var>value</var> is null, then set <a>tokens</a> to the empty
9208+
set.
9209+
9210+
<li><p>Otherwise, <var>localName</var> is associated attribute's <a for=Attr>local name</a>,
9211+
<var>namespace</var> is null, then set <a>tokens</a> to <var>value</var>,
9212+
<a lt="ordered set parser">parsed</a>.
9213+
</ol>
9214+
9215+
<p>When a {{DOMTokenList}} object is created, run these substeps:
9216+
9217+
<ol>
9218+
<li><p>Let <var>element</var> be associated <a for=/>element</a>.
9219+
9220+
<li><p>Let <var>localName</var> be associated attribute's <a for=Attr>local name</a>.
9221+
9222+
<li><p>Let <var>value</var> be the result of
9223+
<a lt="get an attribute by namespace and local name">getting an attribute</a> given null,
9224+
<var>localName</var>, and <var>element</var>.
9225+
9226+
<li><p>Run the <a>attribute change steps</a> for <var>element</var>, <var>localName</var>,
9227+
<var>value</var>, <var>value</var>, and null.
9228+
</ol>
92179229

92189230
<dl class="domintro">
92199231
<dt><code><var>tokenlist</var> . {{DOMTokenList/length}}</code>

0 commit comments

Comments
 (0)