Skip to content

Commit 8c62e75

Browse files
Abstract away comon logic in toggleAttribute() and setAttribute() to be simpler
1 parent 2325396 commit 8c62e75

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

dom.bs

+20-22
Original file line numberDiff line numberDiff line change
@@ -6189,6 +6189,24 @@ in an <a for="/">element</a> <var>element</var>, run these steps:
61896189

61906190
<hr>
61916191

6192+
To <dfn export id=concept-element-attributes-get-valid-by-name>get a valid attribute by name</dfn>
6193+
given a <var>qualifiedName</var>, and <a for="/">element</a> <var>element</var>, run these steps:
6194+
6195+
<ol>
6196+
<li><p>If <var>qualifiedName</var> does not match the <code><a type>Name</a></code> production in
6197+
XML, then <a>throw</a> an "{{InvalidCharacterError!!exception}}" {{DOMException}}.
6198+
6199+
<li><p>If <var>element</var> is in the <a>HTML namespace</a> and its <a for=Node>node document</a>
6200+
is an <a>HTML document</a>, then set <var>qualifiedName</var> to <var>qualifiedName</var> in
6201+
<a>ASCII lowercase</a>.
6202+
6203+
<!-- This is step 2 of "get an attribute by name", modified as appropriate -->
6204+
<li><p>Let <var>attribute</var> be the first <a>attribute</a> in <var>element</var>'s <a for=Element>attribute list</a>
6205+
whose <a for=Attr>qualified name</a> is <var>qualifiedName</var>, and null otherwise.
6206+
6207+
<li>Return <var>qualifiedName</var>, and <var>attribute</var>.
6208+
</ol>
6209+
61926210
To <dfn export id=concept-element-attributes-get-by-name>get an attribute by name</dfn> given a
61936211
<var>qualifiedName</var> and <a for="/">element</a> <var>element</var>, run these steps:
61946212

@@ -6528,17 +6546,7 @@ method, when invoked, must these steps:
65286546
method, when invoked, must run these steps:
65296547

65306548
<ol>
6531-
<li><p>If <var>qualifiedName</var> does not match the <code><a type>Name</a></code> production in
6532-
XML, then <a>throw</a> an "{{InvalidCharacterError!!exception}}" {{DOMException}}.
6533-
6534-
<li><p>If the <a>context object</a> is in the <a>HTML namespace</a> and its
6535-
<a for=Node>node document</a> is an <a>HTML document</a>, then set <var>qualifiedName</var> to
6536-
<var>qualifiedName</var> in <a>ASCII lowercase</a>.
6537-
6538-
<li><p>Let <var>attribute</var> be the first <a>attribute</a> in <a>context object</a>'s
6539-
<a for=Element>attribute list</a> whose <a for=Attr>qualified name</a> is <var>qualifiedName</var>,
6540-
and null otherwise.
6541-
<!-- This is step 2 of "get an attribute by name", modified as appropriate -->
6549+
<li><p>Let <var>qualifiedName</var> and <var>attribute</var> be the result of running <a>get a valid attribute by name</a> given the <var>qualifiedName</var> and <a>context object</a>
65426550

65436551
<li><p>If <var>attribute</var> is null, create an <a>attribute</a> whose
65446552
<a for="Attr">local name</a> is <var>qualifiedName</var>, <a for=Attr>value</a> is
@@ -6590,17 +6598,7 @@ when invoked, must run these steps:
65906598
method, when invoked, must run these steps:
65916599

65926600
<ol>
6593-
<li><p>If <var>qualifiedName</var> does not match the <code><a type>Name</a></code> production in
6594-
XML, then <a>throw</a> an "{{InvalidCharacterError!!exception}}" {{DOMException}}.
6595-
6596-
<li><p>If the <a>context object</a> is in the <a>HTML namespace</a> and its
6597-
<a for=Node>node document</a> is an <a>HTML document</a>, then set <var>qualifiedName</var> to
6598-
<var>qualifiedName</var> in <a>ASCII lowercase</a>.
6599-
6600-
<li><p>Let <var>attribute</var> be the first <a>attribute</a> in the <a>context object</a>'s
6601-
<a for=Element>attribute list</a> whose <a for=Attr>qualified name</a> is <var>qualifiedName</var>,
6602-
and null otherwise.
6603-
<!-- This is step 2 of "get an attribute by name", modified as appropriate -->
6601+
<li><p>Let <var>qualifiedName</var> and <var>attribute</var> be the result of running <a>get a valid attribute by name</a> given the <var>qualifiedName</var> and <a>context object</a>
66046602

66056603
<li>
66066604
<p>If <var>attribute</var> is null, then:

0 commit comments

Comments
 (0)