-
Notifications
You must be signed in to change notification settings - Fork 378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need callback for form submit data #187
Comments
Here is my proposal for addressing this issue: http://dave-ford.blogspot.com/2016/06/web-components-and-form-submit-fields.html |
Custom elements F2F: we would like this! Previously, https://lists.w3.org/Archives/Public/public-webapps/2014JanMar/0448.html Current thinking is:
|
The last point is why we decided to use string & JSON for the value so that we can use Using Yet anther option is to let users of component specify names for each value the component supplies but this is very different from the way builtin elements work so probably not a good idea. |
@domenic if it is |
Yes |
Awesome. But since you tagged it v2: If it does come into the specs it will probably be a year or more, correct? Since v1 is just releases and not even really implemented anywhere. |
No, "v2" is a misnomer. The specs are living and see continuous changes, and implementations implement those changes as they can prioritize them, according to each implementation's individual release cycle. In the issue tracker, "v2" means something roughly like "not part of the initial set of features that we reached consensus on in the January 2016 face to face meeting". |
Ahh, I see. Thanks for the clarification. Where can I best track the progress of this, to see if/when it will come? |
Watching this issue is the best way to get updated on spec progress. After that, the procedure is specific to each browser; places like the various browser status trackers or bug trackers will be where implementation-specific discussion happens. That's kind of outside the scope of this repo though. |
Has there been any progress on this? We want to develop internal components that are project/framework agnostic. Ideally we want to be able to support Angular, React, and MVC patterns. The last one is the sticking point. Several of the components I want to build are basically form elements so I should be able to drop them in a form and submit with no additional code needed. Is there a workaround to support submitting the component's values with the enclosing form on submit? |
@PleasantD the only workarounds we've been able to find are to replicate the behaviour of form elements (which requires you to also to replicate Replicating form and input behaviour is robust, and allows you to keep shadow DOM encapsulation, but can work well when implemented correctly and edge-cases are tested. We've documented roughly how to do this here: https://skatejs.gitbooks.io/skatejs/content/docs/recipes/form-behaviour-and-the-shadow-dom.html. This can work with any web component library, not just Skate. The downfall here is that your custom Not using shadow DOM works well for leaf nodes. Luckily, most form elements are leaf nodes. However, it falls short when you want to use the custom element in a library that takes over control of You could try and use the |
We've made a concrete proposal three years ago in https://lists.w3.org/Archives/Public/public-webapps/2014JanMar/0448.html |
I also think so. We don't need incompatible changes against whatwg/html#4383 in order to resolve known issues. So, we, Chromium project, would like to start shipping process of both of event-based participation and form-associated custom element early next week. Does anyone still want to review these APIs? |
This is for WICG/webcomponents#187 Specification PR: whatwg/html#4383
This is for WICG/webcomponents#187. Specification PR: whatwg/html#4383.
Thanks everyone who accompanied us on this four-year journey!! On top of the feature that just got merged into the HTML spec, we have the following follow-up issues to make custom elements EVEN MORE powerful and on par with built-in elements:
|
I added a section to the proposal document for a list of follow-up issues. |
…ements', a=testonly Automatic update from web-platform-tests Add tests for form-associated custom elements This is for WICG/webcomponents#187. Specification PR: whatwg/html#4383. -- wp5At-commits: 3ccd79e32ced5ddab58f52e79f982d2ebfc7f98c wpt-pr: 15740
…ements', a=testonly Automatic update from web-platform-tests Add tests for form-associated custom elements This is for WICG/webcomponents#187. Specification PR: whatwg/html#4383. -- wp5At-commits: 3ccd79e32ced5ddab58f52e79f982d2ebfc7f98c wpt-pr: 15740
This is for WICG/webcomponents#187. Specification PR: whatwg/html#4383.
…ements', a=testonly Automatic update from web-platform-tests Add tests for form-associated custom elements This is for WICG/webcomponents#187. Specification PR: whatwg/html#4383. -- wp5At-commits: 3ccd79e32ced5ddab58f52e79f982d2ebfc7f98c wpt-pr: 15740 UltraBlame original commit: 10764d9717ef7db00aa99d016a50f282e0d9d7b1
…ements', a=testonly Automatic update from web-platform-tests Add tests for form-associated custom elements This is for WICG/webcomponents#187. Specification PR: whatwg/html#4383. -- wp5At-commits: 3ccd79e32ced5ddab58f52e79f982d2ebfc7f98c wpt-pr: 15740 UltraBlame original commit: 10764d9717ef7db00aa99d016a50f282e0d9d7b1
…ements', a=testonly Automatic update from web-platform-tests Add tests for form-associated custom elements This is for WICG/webcomponents#187. Specification PR: whatwg/html#4383. -- wp5At-commits: 3ccd79e32ced5ddab58f52e79f982d2ebfc7f98c wpt-pr: 15740 UltraBlame original commit: 10764d9717ef7db00aa99d016a50f282e0d9d7b1
@tkent-google, are you still looking for feedback on the doc here? Just two notes:
|
I'm trying to build a form-associated web component and I've been able to get the example up and running.
or a number of callbacks like It will be interesting to see how this will get implemented from the MWC team: |
@dflorey Overriding |
Not sure if I understand correctly. In the given sample in the doc... ....and in all other examples that I've found it is also a bit weird that the validity will be set whenever the input changes as this is may be a very expensive operation. I'd also expect to have a but this seems not to work (quite yet)? It would be so cool to be able to implement a custom element that can be used as a drop-in replacement for native input fields or to add new exciting input controls, but right now I don't see a way to do so due to the issues above.
|
Title: [Custom]: Need callback for form submit data (bugzilla: 24603)
Migrated from: https://www.w3.org/Bugs/Public/show_bug.cgi?id=24603
comment: 0
comment_url: https://www.w3.org/Bugs/Public/show_bug.cgi?id=24603#c0
Erik Arvidsson wrote on 2014-02-10 16:09:15 +0000.
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:
comment: 1
comment_url: https://www.w3.org/Bugs/Public/show_bug.cgi?id=24603#c1
Boris Zbarsky wrote on 2014-02-10 16:20:44 +0000.
If is a subclass of , why can't it just set the .value to the thing it wants to submit?
If it's not a subclass of , you have other problems too, like form validation not knowing anything about it and so forth...
comment: 2
comment_url: https://www.w3.org/Bugs/Public/show_bug.cgi?id=24603#c2
Erik Arvidsson wrote on 2014-02-10 16:30:48 +0000.
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.
comment: 3
comment_url: https://www.w3.org/Bugs/Public/show_bug.cgi?id=24603#c3
Boris Zbarsky wrote on 2014-02-10 16:37:53 +0000.
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....
comment: 4
comment_url: https://www.w3.org/Bugs/Public/show_bug.cgi?id=24603#c4
Anne wrote on 2014-02-12 18:16:49 +0000.
What about form association and label association? It seems you need hooks for those too.
comment: 5
comment_url: https://www.w3.org/Bugs/Public/show_bug.cgi?id=24603#c5
Dimitri Glazkov wrote on 2014-05-08 20:51:20 +0000.
There's another proposal here: http://lists.w3.org/Archives/Public/public-webapps/2014JanMar/0448.html
The text was updated successfully, but these errors were encountered: