Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Abstract away creating an attribute from toggleAttribute() and setAtt…
…ribute()
  • Loading branch information
jonathanKingston committed Jun 29, 2018
commit 543336cbb36a6a2aa93a883f38048b604cff9f6c
31 changes: 19 additions & 12 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -6189,6 +6189,22 @@ in an <a for="/">element</a> <var>element</var>, run these steps:

<hr>


To <dfn export id=concept-element-attributes-set-by-name>create an attribute by value</dfn>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should name this "create and append an attribute"? Or maybe I don't understand "by value".

The other thing I'm thinking is that it would be nice if https://dom.spec.whatwg.org/#concept-element-attributes-set-value could invoke this algorithm as well. That would require additional arguments for namespace/prefix, but seems doable.

given a <var>qualifiedName</var>, <var>value</var> and <a for="/">element</a> <var>element</var>, run these steps:

<ol>
<li><p>Create an <a>attribute</a> whose
<a for="Attr">local name</a> is <var>qualifiedName</var>, <a for=Attr>value</a> is
<var>value</var>, and <a for=Node>node document</a> is <a>context object</a>'s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the context object* throughout

<a for=Node>node document</a>.

<li><a lt="append an attribute">Append</a> this <a>attribute</a> to
<a>element</a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want <var>element</var> here and a dot.


<li>Return.
</ol>

To <dfn export id=concept-element-attributes-get-valid-by-name>get a valid attribute by name</dfn>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"validate and get an attribute by name" perhaps?

given a <var>qualifiedName</var>, and <a for="/">element</a> <var>element</var>, run these steps:

Expand Down Expand Up @@ -6548,11 +6564,8 @@ method, when invoked, must run these steps:
<ol>
<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
<var>value</var>, and <a for=Node>node document</a> is <a>context object</a>'s
<a for=Node>node document</a>, then <a lt="append an attribute">append</a> this <a>attribute</a> to
<a>context object</a>, and then return.

<li><p>If <var>attribute</var> is null, run <a>create an attribute by value</a> given the <var>qualifiedName</var>, <var>value</var> and <a>context object</a>, and then return.

<li><p><a lt="change an attribute">Change</a> <var>attribute</var> from <a>context object</a> to
<var>value</var>.
Expand Down Expand Up @@ -6606,13 +6619,7 @@ method, when invoked, must run these steps:
<ol>
<li><p>If <var>force</var> is given and is false, return false.

<li><p>Create an <a>attribute</a> whose
<a for="Attr">local name</a> is <var>qualifiedName</var>, <a for=Attr>value</a> is the empty
string, and <a for=Node>node document</a> is the <a>context object</a>'s
<a for=Node>node document</a>.

<li><a lt="append an attribute">Append</a> this <a>attribute</a>
to the <a>context object</a>.
<li><p>Run <a>create an attribute by value</a> given the <var>qualifiedName</var>, <var>the empty string</var> and <a>context object</a>.

<li>Return true.
</ol>
Expand Down