You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In preparation for [basecamp#1128][], this commit introduces a module-private
`Delegate` class to serve as a representation of what form integration
requires for the `<trix-editor>` custom element. The structure of the
`Delegate` class mirrors that of the `TrixEditorElement` from which its
contents are extracted.
First, there are the properties that mimic those of most form controls,
including:
* `labels`
* `form`
* `name`
* `value`
* `defaultValue`
With the exception of `labels`, property access is mostly proxied
through the associated `<input type="hidden">` element (accessed through
its own `inputElement` property).
Next, the `Delegate` defines methods that correspond to the Custom
Element lifecycle events, including:
* `connectedCallback`
* `disconnectedCallback`
* `setFormValue`
The connected and disconnected callbacks mirror that of the
`TrixEditorElement` itself. These callbacks attach and remove event
listeners for `click` and `reset` events.
The `setFormValue` is named to correspond with
[ElementInternals.setFormValue][]. Along with introducing this callback
method, this commit renames the `TrixEditorElement.setInputElementValue`
method to `TrixEditorElement.setFormValue`.
In addition to renaming `setInputElementValue`, this commit also defines
`TrixEditorElement.formResetCallback`, then implements
`TrixEditorElement.reset` as an alias. The name mirrors the
[ElementInternals.formResetCallback][].
[basecamp#1128]: basecamp#1128
[ElementInternals.setFormValue]: https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/setFormValue
[ElementInternals.formResetCallback]: https://web.dev/articles/more-capable-form-controls#void_formresetcallback
0 commit comments