{"action":"created","issue":{"url":"https://api.github.com/repos/w3c/webcomponents/issues/187","repository_url":"https://api.github.com/repos/w3c/webcomponents","labels_url":"https://api.github.com/repos/w3c/webcomponents/issues/187/labels{/name}","comments_url":"https://api.github.com/repos/w3c/webcomponents/issues/187/comments","events_url":"https://api.github.com/repos/w3c/webcomponents/issues/187/events","html_url":"https://github.com/w3c/webcomponents/issues/187","id":93212883,"number":187,"title":"[Custom]: Need callback for form submit data (bugzilla: 24603)","user":{"login":"hayatoito","id":160288,"avatar_url":"https://avatars.githubusercontent.com/u/160288?v=3","gravatar_id":"","url":"https://api.github.com/users/hayatoito","html_url":"https://github.com/hayatoito","followers_url":"https://api.github.com/users/hayatoito/followers","following_url":"https://api.github.com/users/hayatoito/following{/other_user}","gists_url":"https://api.github.com/users/hayatoito/gists{/gist_id}","starred_url":"https://api.github.com/users/hayatoito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hayatoito/subscriptions","organizations_url":"https://api.github.com/users/hayatoito/orgs","repos_url":"https://api.github.com/users/hayatoito/repos","events_url":"https://api.github.com/users/hayatoito/events{/privacy}","received_events_url":"https://api.github.com/users/hayatoito/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/w3c/webcomponents/labels/custom-elements","name":"custom-elements","color":"5319e7"},{"url":"https://api.github.com/repos/w3c/webcomponents/labels/v2","name":"v2","color":"f7c6c7"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2015-07-06T07:38:09Z","updated_at":"2016-10-13T13:01:26Z","closed_at":null,"body":"Title: [Custom]: Need callback for form submit data (bugzilla: 24603)\n\nMigrated from: https://www.w3.org/Bugs/Public/show_bug.cgi?id=24603\n\n----\ncomment: 0\ncomment_url: https://www.w3.org/Bugs/Public/show_bug.cgi?id=24603#c0\n*Erik Arvidsson* wrote on 2014-02-10 16:09:15 +0000.\n\n\\<form\\>\n  \\<my-custom-input name=\"abc\">\\</my-custom-input\\>\n\\</form\\>\n\nRight now there is no way to have custom elements include data in form submissions. We should add another callback for this\n\nI believe we need to add a callback that is called before the submit event.\n\nStrawman:\n\ndocument.registerElement('input', {\n  prototype: {\n    __proto__: HTMLElement.prototype,\n    beforeSubmitCallback: function() {\n      switch (this.type) {\n        case 'checkbox';\n          if (this.checked)\n            return this.value;\n          return undefined;\n        ...\n      }      \n    }\n }\n});\n\nBasically, the contract is that the return value of the callback is used a the form value. If undefined is returned nothing is serialized.\n\nThis is of course a bit too simplistic but it might be enough to get started.\n\nThings to keep in mind:\n\n- Radio buttons need to check outside itself\n- input[type=file]. Return Blob|File|data url?\n- input[multiple]. Array of values?\n\n----\n\ncomment: 1\ncomment_url: https://www.w3.org/Bugs/Public/show_bug.cgi?id=24603#c1\n*Boris Zbarsky* wrote on 2014-02-10 16:20:44 +0000.\n\nIf \\<my-custom-input\\> is a subclass of \\<input\\>, why can't it just set the .value to the thing it wants to submit?\n\nIf it's not a subclass of \\<my-custom-input\\>, you have other problems too, like form validation not knowing anything about it and so forth...\n\n----\n\ncomment: 2\ncomment_url: https://www.w3.org/Bugs/Public/show_bug.cgi?id=24603#c2\n*Erik Arvidsson* wrote on 2014-02-10 16:30:48 +0000.\n\nI 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.\n\n----\n\ncomment: 3\ncomment_url: https://www.w3.org/Bugs/Public/show_bug.cgi?id=24603#c3\n*Boris Zbarsky* wrote on 2014-02-10 16:37:53 +0000.\n\nSure.  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's done in arbitrary script....\n\nThe 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....\n\n----\n\ncomment: 4\ncomment_url: https://www.w3.org/Bugs/Public/show_bug.cgi?id=24603#c4\n*Anne* wrote on 2014-02-12 18:16:49 +0000.\n\nWhat about form association and label association? It seems you need hooks for those too.\n\n----\n\ncomment: 5\ncomment_url: https://www.w3.org/Bugs/Public/show_bug.cgi?id=24603#c5\n*Dimitri Glazkov* wrote on 2014-05-08 20:51:20 +0000.\n\nThere's another proposal here: http://lists.w3.org/Archives/Public/public-webapps/2014JanMar/0448.html"},"comment":{"url":"https://api.github.com/repos/w3c/webcomponents/issues/comments/253506165","html_url":"https://github.com/w3c/webcomponents/issues/187#issuecomment-253506165","issue_url":"https://api.github.com/repos/w3c/webcomponents/issues/187","id":253506165,"user":{"login":"lukasoppermann","id":813754,"avatar_url":"https://avatars.githubusercontent.com/u/813754?v=3","gravatar_id":"","url":"https://api.github.com/users/lukasoppermann","html_url":"https://github.com/lukasoppermann","followers_url":"https://api.github.com/users/lukasoppermann/followers","following_url":"https://api.github.com/users/lukasoppermann/following{/other_user}","gists_url":"https://api.github.com/users/lukasoppermann/gists{/gist_id}","starred_url":"https://api.github.com/users/lukasoppermann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukasoppermann/subscriptions","organizations_url":"https://api.github.com/users/lukasoppermann/orgs","repos_url":"https://api.github.com/users/lukasoppermann/repos","events_url":"https://api.github.com/users/lukasoppermann/events{/privacy}","received_events_url":"https://api.github.com/users/lukasoppermann/received_events","type":"User","site_admin":false},"created_at":"2016-10-13T13:01:26Z","updated_at":"2016-10-13T13:01:26Z","body":"Ahh, I see. Thanks for the clarification. Where can I best track the progress of this, to see if/when it will come?"}}
{"actor":{"display_login":"lukasoppermann"}}