Netflix / x-element

A dead simple starting point for custom elements.
Apache License 2.0
28 stars 12 forks source link

Pull `listeners` block into base classes. #29

Closed theengineear closed 5 years ago

theengineear commented 5 years ago

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:

  1. The target to attach listeners to is the shadowRoot.
  2. 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.