<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>25869</bug_id>
          
          <creation_ts>2014-05-23 00:27:51 +0000</creation_ts>
          <short_desc>DOMClassList.toggle &apos;force&apos; parameter is &quot;wonky API design&quot;</short_desc>
          <delta_ts>2014-08-14 14:57:56 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>DOM</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Robert O&apos;Callahan (Mozilla)">roc</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>crimsteam</cc>
    
    <cc>d</cc>
    
    <cc>erik.arvidsson</cc>
    
    <cc>glenn</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>mjs</cc>
    
    <cc>www-dom</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>106688</commentid>
    <comment_count>0</comment_count>
    <who name="Robert O&apos;Callahan (Mozilla)">roc</who>
    <bug_when>2014-05-23 00:27:51 +0000</bug_when>
    <thetext>The &quot;force&quot; parameter makes the toggle() API not toggle. This seems wrong.

DOMClassList.set(classname, bool) would be much better.

#whatwg feedback, FWIW:
http://krijnhoetmer.nl/irc-logs/whatwg/20140523#l-109</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106693</commentid>
    <comment_count>1</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-05-23 06:49:05 +0000</bug_when>
    <thetext>This is shipping in browsers. E.g. try

&lt;script&gt;
document.body.classList.toggle(&quot;test&quot;, false); document.body.classList.toggle(&quot;x&quot;, true); 
&lt;/script&gt;

in Live DOM Viewer or some such. Seems like a pain to change now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106696</commentid>
    <comment_count>2</comment_count>
    <who name="Robert O&apos;Callahan (Mozilla)">roc</who>
    <bug_when>2014-05-23 09:19:01 +0000</bug_when>
    <thetext>OK, but is it used yet?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106697</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-05-23 09:21:08 +0000</bug_when>
    <thetext>I guess someone would need to add telemetry / use counters to browsers. I can&apos;t answer that question.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107017</commentid>
    <comment_count>4</comment_count>
    <who name="Domenic Denicola">d</who>
    <bug_when>2014-05-30 05:51:47 +0000</bug_when>
    <thetext>I strongly disagree with this bug. &quot;Toggling something to true&quot; is a very common phrase in English. Even if it were not, jQuery&apos;s usage of it as such for many years has made it a common developer expectation. In fact, I remember specific developer complaints that classList&apos;s toggle did *not* have this functionality, back in the day: a kind of &quot;why didn&apos;t they just copy jQuery; they still Just Don&apos;t Get It&quot; diatribe.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107026</commentid>
    <comment_count>5</comment_count>
    <who name="Glenn Maynard">glenn</who>
    <bug_when>2014-05-30 14:02:21 +0000</bug_when>
    <thetext>No, it&apos;s definitely a bad, unintuitive API.  I would never expect x.toggle(true) to mean &quot;set x to true&quot;.  It should have been &quot;x.set(true/false)&quot;.  We shouldn&apos;t copy bad APIs from jQuery because we think people will scoff at us for doing things better.

However, I don&apos;t know if it&apos;s worth the effort it would take to find out if we can change this, and then to change it, with it already implemented in multiple browsers.  It&apos;s probably just another ugly API that we&apos;ll have to live with.

We could add set(value) and leave toggle(value) in, but then we pay the cost of redundant APIs, which is probably worse.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107031</commentid>
    <comment_count>6</comment_count>
    <who name="Glenn Maynard">glenn</who>
    <bug_when>2014-05-30 14:38:47 +0000</bug_when>
    <thetext>(In reply to Domenic Denicola from comment #4)
&gt; I strongly disagree with this bug. &quot;Toggling something to true&quot; is a very
&gt; common phrase in English.

To clarify, &quot;toggle something to X&quot; isn&apos;t what &quot;toggle&quot; actions mean; the word programmers use is &quot;set&quot; (or &quot;assign&quot;, or occasionally &quot;put&quot; or &quot;write&quot;, but never &quot;toggle&quot;).  &quot;Toggle&quot; means a change based on the previous state.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107032</commentid>
    <comment_count>7</comment_count>
    <who name="Domenic Denicola">d</who>
    <bug_when>2014-05-30 14:42:44 +0000</bug_when>
    <thetext>I disagree that the word programmers use is &quot;set.&quot; The word programmers use is often &quot;toggle,&quot; especially in the case of classes, visibility, or animations.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107203</commentid>
    <comment_count>8</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-06-03 13:49:14 +0000</bug_when>
    <thetext>This was not fixed. It might be WONTFIX, but that depends on research per comment 3.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>