Re: [WICG/webcomponents] The is="" attribute is confusing? Maybe we should encourage only ES6 class-based extension. (#509)

@trusktr more concerns while quickly implementing an alternative/proposal to experiment with:
  * the `disconnectedCallback` called when the `has` attribute changes and the behavior is removed is misleading, as it's not about the element being disconnected but about the behavior being disconnected. Unless the intention is indeed to simply have connected and disconnected run **only** when the behavior is added or removed, I find this part hard to reason about.
  * similarly, the `connectedCallback`. It's not clear if it should be called when the element attribute changes (i.e. via element.behaviors.add('behavior')) even if the element is offline.
  * if these callbacks are bound to the element lifecycle, the `disconnectedCallback` for cleanup sounds footgun proof, because when a behavior is removed (i.e. via behaviors.remove('behavior')), but the element is still live, it looks like we're simulating a `destructor` instead, not a disconnect.
  * it's not clear if offline elements will work as expected (at least with a MO that observes only live nodes)
  * it's not clear if trashing layout would invoke disconnected (but it'd expect so)
  * it's not clear if injecting in templates via html would connect behaviors, or only once document.importNode(template.content, true) happens
  * it's not clear if adding and removing the same behavior would use the same instance or create a new one

Thanks for clarifications.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/509#issuecomment-804855205

Received on Tuesday, 23 March 2021 12:16:43 UTC