<?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>13681</bug_id>
          
          <creation_ts>2011-08-05 05:41:19 +0000</creation_ts>
          <short_desc>Make FormData.append return the FormData object</short_desc>
          <delta_ts>2012-11-22 21:58:14 +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>XHR</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</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="Jonas Sicking (Not reading bugmail)">jonas</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>mike</cc>
    
    <cc>public-webapps</cc>
    
    <cc>waldron.rick</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>54217</commentid>
    <comment_count>0</comment_count>
    <who name="Jonas Sicking (Not reading bugmail)">jonas</who>
    <bug_when>2011-08-05 05:41:19 +0000</bug_when>
    <thetext>If we change the FormData.append function to return the FormData object on which the function was called, it would allow syntax like

myformdata.append(&quot;foo&quot;, file).append(&quot;bar&quot;, &quot;text&quot;).append(&quot;baz&quot;, blob);

as well as

xhr.send((new FormData).append(&quot;afile&quot;, myfile));</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54220</commentid>
    <comment_count>1</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-08-05 08:23:58 +0000</bug_when>
    <thetext>We do not use that pattern anywhere else as far as I know.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>55323</commentid>
    <comment_count>2</comment_count>
    <who name="Jonas Sicking (Not reading bugmail)">jonas</who>
    <bug_when>2011-08-17 16:53:09 +0000</bug_when>
    <thetext>That&apos;s a terrible reason not to do something! There are lots of things that the DOM didn&apos;t used to do but which were a good idea and that we&apos;re slowly starting to do now.

Do you have a technical reason why you don&apos;t think we should provide the nicer syntax in comment 0?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>55359</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-08-17 22:19:07 +0000</bug_when>
    <thetext>Is it established chaining is a good idea? What other APIs use this?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>55363</commentid>
    <comment_count>4</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-08-17 22:21:20 +0000</bug_when>
    <thetext>There are lots of DOM methods that could adopt this syntax.  It&apos;s one of the things that helps make jQuery concise: you can chain repeated method calls without having to repeat the thing you&apos;re calling it on.  In many cases you can completely avoid temporaries.  Like consider

  document.body.appendChild(document.createElement(&quot;foo&quot;)
    .setAttribute(&quot;bar&quot;, &quot;baz&quot;)
    .setAttribute(&quot;quz&quot;, &quot;qoz&quot;));

vs.

  var element = document.createElement(&quot;foo&quot;);
  element.setAttribute(&quot;bar&quot;, &quot;baz&quot;);
  element.setAttribute(&quot;quz&quot;, &quot;qoz&quot;);
  document.body.appendChild(element);

which is one extra line with an extra temporary.  Is there any reason we shouldn&apos;t adopt this convention across the board for DOM methods with void return type?  Compat risk is conceivable, but I shouldn&apos;t think it&apos;s at all certain, and it seems worth it to try.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78610</commentid>
    <comment_count>5</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-11-21 21:25:51 +0000</bug_when>
    <thetext>Once ECMAScript adopts this pattern, and looking at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Map it won&apos;t, we should consider it, no sooner imo.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78667</commentid>
    <comment_count>6</comment_count>
    <who name="Rick Waldron">waldron.rick</who>
    <bug_when>2012-11-22 21:58:14 +0000</bug_when>
    <thetext>I&apos;ve added an agenda item for the coming TC39 meeting to discuss |this| returns in new API. See also: http://lists.w3.org/Archives/Public/public-script-coord/2012OctDec/0164.html</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>