Netflix / x-element

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

No way to listen to errors dispatched during initialization. #22

Closed theengineear closed 5 years ago

theengineear commented 5 years ago

Currently, our pattern is to call .dispatchError such that some integrator can do .addEventListener('error', () => { /* .. */ }) and listen to errors from children. However, errors can happen during connection.

We need to do something different here since we're missing signals about errors which can cause silent failures.

theengineear commented 5 years ago

@klebba ran into this one recently and did a lot of head-scratching before I realized what was going on. I think there are two options:

  1. defer more initialization until first connectedCallback
  2. fork logic and console.error when not connected (hate this idea, we're not doing this)
  3. hard-throw errors during initialization (also dislike this...)

I'm sort of leaning towards (1). We can still do everything synchronously, but we just do a little less during construction, preferring to wait until connectedCallback.

In particular, any reservations to deferring property analysis until first connected callback?

theengineear commented 5 years ago

^^ I went ahead and made this change locally. It's much, much better. One side effect here is that we can see previously-hidden setup errors in demos again 🥇. Additionally, it's possible to test for these errors in /test 🥈.