<?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>24603</bug_id>
          
          <creation_ts>2014-02-10 16:09:15 +0000</creation_ts>
          <short_desc>[Custom]: Need callback for form submit data</short_desc>
          <delta_ts>2015-07-06 08:04:13 +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>HISTORICAL - Component Model</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>MOVED</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>
          
          <blocked>14968</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Erik Arvidsson">erik.arvidsson</reporter>
          <assigned_to name="Dimitri Glazkov">dglazkov</assigned_to>
          <cc>annevk</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>hober0</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>public-webapps</cc>
    
    <cc>rniwa</cc>
    
    <cc>wchen</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>100169</commentid>
    <comment_count>0</comment_count>
    <who name="Erik Arvidsson">erik.arvidsson</who>
    <bug_when>2014-02-10 16:09:15 +0000</bug_when>
    <thetext>&lt;form&gt;
  &lt;my-custom-input name=&quot;abc&quot;&gt;&lt;/my-custom-input&gt;
&lt;/form&gt;

Right now there is no way to have custom elements include data in form submissions. We should add another callback for this

I believe we need to add a callback that is called before the submit event.

Strawman:

document.registerElement(&apos;input&apos;, {
  prototype: {
    __proto__: HTMLElement.prototype,
    beforeSubmitCallback: function() {
      switch (this.type) {
        case &apos;checkbox&apos;;
          if (this.checked)
            return this.value;
          return undefined;
        ...
      }      
    }
 }
});

Basically, the contract is that the return value of the callback is used a the form value. If undefined is returned nothing is serialized.

This is of course a bit too simplistic but it might be enough to get started.

Things to keep in mind:

- Radio buttons need to check outside itself
- input[type=file]. Return Blob|File|data url?
- input[multiple]. Array of values?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100170</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-02-10 16:20:44 +0000</bug_when>
    <thetext>If &lt;my-custom-input&gt; is a subclass of &lt;input&gt;, why can&apos;t it just set the .value to the thing it wants to submit?

If it&apos;s not a subclass of &lt;my-custom-input&gt;, you have other problems too, like form validation not knowing anything about it and so forth...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100173</commentid>
    <comment_count>2</comment_count>
    <who name="Erik Arvidsson">erik.arvidsson</who>
    <bug_when>2014-02-10 16:30:48 +0000</bug_when>
    <thetext>I agree it might be simpler to just subclass input but at some point we should explain how input is implemented too. That also includes explaining form validation and requestAutoComplete and probably tons of other things.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100176</commentid>
    <comment_count>3</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-02-10 16:37:53 +0000</bug_when>
    <thetext>Sure.  If we do that we need to make all the relevant algorithms robust to script randomly doing unexpected things.  E.g. getting the value from an input can change the values of other inputs if it&apos;s done in arbitrary script....

The way input is implemented in practice, in ES terms, is that it has private slot (closure variable, weakmap entry, whatever) that stores a value string, and various form operations can retrieve that string without running any untrusted (from the point of view of the form) script in the process.  Whatever setup we come up with for explaining input would be best if it preserved those invariants....</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100418</commentid>
    <comment_count>4</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-02-12 18:16:49 +0000</bug_when>
    <thetext>What about form association and label association? It seems you need hooks for those too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105480</commentid>
    <comment_count>5</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2014-05-08 20:51:20 +0000</bug_when>
    <thetext>There&apos;s another proposal here: http://lists.w3.org/Archives/Public/public-webapps/2014JanMar/0448.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>121634</commentid>
    <comment_count>6</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2015-07-06 08:04:13 +0000</bug_when>
    <thetext>Moved to https://github.com/w3c/webcomponents/issues/187</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>