This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
<form> <my-custom-input name="abc"></my-custom-input> </form> 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('input', { prototype: { __proto__: HTMLElement.prototype, beforeSubmitCallback: function() { switch (this.type) { case 'checkbox'; 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?
If <my-custom-input> is a subclass of <input>, why can't it just set the .value to the thing it wants to submit? If 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...
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.
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'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....
What about form association and label association? It seems you need hooks for those too.
There's another proposal here: http://lists.w3.org/Archives/Public/public-webapps/2014JanMar/0448.html
Moved to https://github.com/w3c/webcomponents/issues/187