Re: [webcomponents] [Custom]: Consider adding inserted/removed callback (bugzilla: 24866) (#222)

If `inserted` and `removed` were to be added in lieu of `attached` and `detached`, then how would a component know when it is attached? Once could call `document.contains(this)`, but that wouldn't be ideal because it's the more common use case and can have performance implications. Keeping `attached` and `detached` would be ideal while adding `inserted` and `removed` to be closer to the DOM spec.

FWIW, I've never had a need for the semantics of `inserted` and `removed` and I've built **a lot** of custom elements. Generally I've found if one needed to use such behaviour that they'd likely be needing it for looking "up" in the DOM, which should be discouraged because it means your components are tightly coupled to a specific DOM structure that they don't have control over.

---
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/222#issuecomment-161464094

Received on Wednesday, 2 December 2015 23:17:17 UTC