We've been playing with the notion of having a static listeners block akin to the properties block which will handle setup / teardown of listeners on connection / disconnection.
There are two important opinions that our listeners block has so far made:
The target to attach listeners to is the shadowRoot.
We will not support additional listeners args (e.g,. capture)
These simplifications have, thus far, been helpful. However, (1) is important because we may not have a shadowRoot in the future, in which case we have to decide if we just fallback to the element itself. It's also important because there are valid use-cases for listening on the host element, not the shadowRoot. For now, you'll just need to manually hook up these listeners using listen and unlisten.
Point (2) seems to be another edge case. Again, if you want to add additional args, the listen and unlisten methods provide for that.
We've been playing with the notion of having a static
listeners
block akin to theproperties
block which will handle setup / teardown of listeners on connection / disconnection.There are two important opinions that our
listeners
block has so far made:shadowRoot
.capture
)These simplifications have, thus far, been helpful. However, (1) is important because we may not have a
shadowRoot
in the future, in which case we have to decide if we just fallback to the element itself. It's also important because there are valid use-cases for listening on the host element, not the shadowRoot. For now, you'll just need to manually hook up these listeners usinglisten
andunlisten
.Point (2) seems to be another edge case. Again, if you want to add additional args, the
listen
andunlisten
methods provide for that.