ACTION-2315: Report on event handling in web components

All,

I played a little with event handling and web components. My goal was to
make sure that two scenarios for bidirectional communication with events
are supported (as they are in our own implementation of components). My
little experiment shows that yes, this bidirectional communication works.

1. It is possible to dispatch an event from the outside of the component to
the custom component element, and to listen to that event from within the
component by attaching an event listener using `this.addEventListener()`,
where `this` points to the instance of the class representing the custom
component.

2. It is possible to dispatch an event from inside the component to the
outside of the component, and to listen to that event from the outside, by
dispatching an event to the custom component using `this.dispatchEvent()`.

At the same time, custom events dispatched inside the component remain
encapsulated in normal situations, although built-in events like `click`
are handled a little differently.

All of this makes sense, of course, and means that we should have a similar
mechanism for subforms.

For reference, here is the code:

    https://gist.github.com/orbeon/a2b6cef690cafd58b3745ad57de3a5a1

-Erik

Received on Friday, 7 October 2022 00:24:43 UTC