Re: [whatwg/dom] Add toggleAttribute to Element. (#656)

annevk commented on this pull request.

Thanks, this looks pretty good. Found a couple nits; please also add your name to the Acknowledgments section.

We'll also need tests and browser bugs.

> @@ -5785,6 +5785,7 @@ interface Element : Node {
   sequence<DOMString> getAttributeNames();
   DOMString? getAttribute(DOMString qualifiedName);
   DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
+  [CEReactions] void toggleAttribute(DOMString qualifiedName, optional boolean force);

You need to change void to boolean here.

> + <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>If <var>attribute</var> is null, then:
+ <ol>
+  <li><p>if <var>force</var> not given or is true, create an <a>attribute</a> whose <a for="Attr">local name</a> is <var>qualifiedName</var>, <a for=Attr>value</a> is
+  <var>true</var>, and <a for=Node>node document</a> is <a>context object</a>'s

Instead of `<var>true</var>` use "the empty string".

> @@ -6541,6 +6548,38 @@ method, when invoked, must run these steps:
  <var>value</var>.
 </ol>
 
+<p>The <dfn method for=Element><code>toggleAttribute(<var>qualifiedName</var>, <var>force</var>)</code></dfn>
+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

**the** context object* throughout

-- 
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/656#pullrequestreview-129968106

Received on Tuesday, 19 June 2018 13:24:16 UTC