Re: [whatwg/dom] Refactor toggle attribute (#663)

annevk commented on this pull request.

I quite like the direction this is going in. We do end up with a few more lines, but it's much more clear what is going on.

> @@ -6189,6 +6189,40 @@ 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>

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.

> @@ -6189,6 +6189,40 @@ 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>
+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
+ <a for=Node>node document</a>.
+
+ <li><a lt="append an attribute">Append</a> this <a>attribute</a> to
+ <a>element</a>

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

> @@ -6189,6 +6189,40 @@ 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>
+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

the context object* throughout

> +To <dfn export id=concept-element-attributes-set-by-name>create an attribute by value</dfn>
+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
+ <a for=Node>node document</a>.
+
+ <li><a lt="append an attribute">Append</a> this <a>attribute</a> to
+ <a>element</a>
+
+ <li>Return.
+</ol>
+
+To <dfn export id=concept-element-attributes-get-valid-by-name>get a valid attribute by name</dfn>

"validate and get an attribute by name" perhaps?

>  
- <li><p>Return true.
+ <li><p><a lt="remove an attribute by name">Remove an attribute</a> given <var>qualifiedName</var> and the
+ <a>context object</a>.
+
+ <li>Return false.

`<li><p>` (also above)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/pull/663#pullrequestreview-145672768

Received on Monday, 13 August 2018 14:18:11 UTC