Re: [w3c/webcomponents] Need callback for form submit data (#187)

> It appears to me that we do need to come up with some mechanism to expose browser engine states and APIs that are only accessible to custom elements implementations.

Yes. We want such APIs. However, we should not make ```ShadowRoot``` mandatory for custom elements.  We should introduce a dedicated interface instead.  For example,

```
dictionary ValidityStateFlags {
  boolean valueMissing = false;
  boolean typeMismatch = false;
  boolean patternMismatch = false;
  boolean tooLong = false;
  boolean tooShort = false;
  boolean rangeUnderflow = false;
  boolean rangeOverflow = false;
  boolean stepMismatch = false;
  boolean badInput = false;
};

interface HTMLElementPrimitives {
  void setFormControlValue(DOMString value);
  void setValidityState(ValidityStateFlags flags);
  ...
};
```
```
class MyControl extends HTMLElement {
  // New lifecycle callback?  'connectedCallback' is too late. Form control value is
  // meaningful even if an element is disconnected.
  // UA creates an HTMLElementPrimitives object for this element, and passes it here.
  void createdCallback(primitives) {
    this._primitives = primitives;
    primitives.setFormControlValue(this.getAttribute('value'));
  }

  set value(v) {
    ...
    this._primitives.setFormControlValue(v);
  }

```


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/187#issuecomment-388740230

Received on Monday, 14 May 2018 08:39:01 UTC