Skip to content

Commit

Permalink
Abstract away comon logic in toggleAttribute() and setAttribute() to …
Browse files Browse the repository at this point in the history
…be simpler
  • Loading branch information
jonathanKingston committed Jun 29, 2018
1 parent 2325396 commit 8c62e75
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -6189,6 +6189,24 @@ in an <a for="/">element</a> <var>element</var>, run these steps:

<hr>

To <dfn export id=concept-element-attributes-get-valid-by-name>get a valid attribute by name</dfn>
given a <var>qualifiedName</var>, and <a for="/">element</a> <var>element</var>, run these steps:

<ol>
<li><p>If <var>qualifiedName</var> does not match the <code><a type>Name</a></code> production in
XML, then <a>throw</a> an "{{InvalidCharacterError!!exception}}" {{DOMException}}.

<li><p>If <var>element</var> is in the <a>HTML namespace</a> and its <a for=Node>node document</a>
is an <a>HTML document</a>, then set <var>qualifiedName</var> to <var>qualifiedName</var> in
<a>ASCII lowercase</a>.

<!-- This is step 2 of "get an attribute by name", modified as appropriate -->
<li><p>Let <var>attribute</var> be the first <a>attribute</a> in <var>element</var>'s <a for=Element>attribute list</a>
whose <a for=Attr>qualified name</a> is <var>qualifiedName</var>, and null otherwise.

<li>Return <var>qualifiedName</var>, and <var>attribute</var>.
</ol>

To <dfn export id=concept-element-attributes-get-by-name>get an attribute by name</dfn> given a
<var>qualifiedName</var> and <a for="/">element</a> <var>element</var>, run these steps:

Expand Down Expand Up @@ -6528,17 +6546,7 @@ method, when invoked, must these steps:
method, when invoked, must run these steps:

<ol>
<li><p>If <var>qualifiedName</var> does not match the <code><a type>Name</a></code> production in
XML, then <a>throw</a> an "{{InvalidCharacterError!!exception}}" {{DOMException}}.

<li><p>If the <a>context object</a> is in the <a>HTML namespace</a> and its
<a for=Node>node document</a> is an <a>HTML document</a>, then set <var>qualifiedName</var> to
<var>qualifiedName</var> in <a>ASCII lowercase</a>.

<li><p>Let <var>attribute</var> be the first <a>attribute</a> in <a>context object</a>'s
<a for=Element>attribute list</a> whose <a for=Attr>qualified name</a> is <var>qualifiedName</var>,
and null otherwise.
<!-- This is step 2 of "get an attribute by name", modified as appropriate -->
<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>

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

<ol>
<li><p>If <var>qualifiedName</var> does not match the <code><a type>Name</a></code> production in
XML, then <a>throw</a> an "{{InvalidCharacterError!!exception}}" {{DOMException}}.

<li><p>If the <a>context object</a> is in the <a>HTML namespace</a> and its
<a for=Node>node document</a> is an <a>HTML document</a>, then set <var>qualifiedName</var> to
<var>qualifiedName</var> in <a>ASCII lowercase</a>.

<li><p>Let <var>attribute</var> be the first <a>attribute</a> in the <a>context object</a>'s
<a for=Element>attribute list</a> whose <a for=Attr>qualified name</a> is <var>qualifiedName</var>,
and null otherwise.
<!-- This is step 2 of "get an attribute by name", modified as appropriate -->
<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>

<li>
<p>If <var>attribute</var> is null, then:
Expand Down

0 comments on commit 8c62e75

Please sign in to comment.