Re: Form submission participation (was Re: Goals for Shadow DOM review)

On Feb 21, 2014, at 2:12 PM, Edward O'Connor <eoconnor@apple.com> wrote:
> Ryosuke wrote:
> 
>> What if we added "formparticipant" boolean content attribute and fired
>> "formdata" event during form submission to serialize data?
>> 
>> This way, we can add more events like "validate" to support more
>> features of builtin form elements.
> 
> Hmm, right, validation. In the model I have in my head, there are
> roughly two kinds of custom form participants: custom form controls
> (probably implemented with custom elements & other web components
> features) and "application state" (JS objects with no corresponding DOM
> presence but that nevertheless should be submittable).
> 
> Suppose in the first case we add a nonconfigurable boolean property to
> Element. The engine inspects this property to determine validity, and
> it's the responsibility of the component to keep the property up to
> date. That way, we don't have to invoke userland JS when performing form
> validation or when resolving :valid/:invalid style rules.

Right.  We may want to move "willValidate", "validity", "validationMessage", "checkValidity()", "reportValidity()" and "setCustomValidity(DOMString error)" IDL attributes from HTMLInputElement to HTMLElement, and make ValidityState's IDL attributes settable on HTMLElement or add a method to update validity states.

> In the second case, I think we can just punt completely—form
> participants that aren't Elements don't participate in validation, only
> submission. Because it's the application's responsibility for
> maintaining its own state, there's no sensible visual location in the
> document to display a validation error, and no no-application-specific
> way for the user to resolve the issue.

Right.  Since HTML spec already assumes some UI to exist to show validation messages for builtin form controls, I don't think it makes sense for UA to validate form data not associated with any element in the document.

- R. Niwa

Received on Saturday, 22 February 2014 02:37:30 UTC