Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
hayatoito opened this issue Jul 6, 2015 · 2 comments
Closed

Comments

@hayatoito
Copy link
Contributor

Title: [Custom]: Consider adding inserted/removed callback (bugzilla: 24866)

Migrated from: https://www.w3.org/Bugs/Public/show_bug.cgi?id=24866


comment: 0
comment_url: https://www.w3.org/Bugs/Public/show_bug.cgi?id=24866#c0
Dimitri Glazkov wrote on 2014-02-28 18:23:40 +0000.

These will be mapped exactly to inserted/removed hooks in DOM core:

Based on discussion in bug 24314, we could even deprecate attached/detached callback in their favor.


comment: 1
comment_url: https://www.w3.org/Bugs/Public/show_bug.cgi?id=24866#c1
Scott Miles wrote on 2014-02-28 19:03:17 +0000.

It's definitely appealing to expose DOM core with high fidelity, but we have some performance realities that concern me.

In particular, calling back into JS from the native side is known to expensive (at least on some platforms).

The currently spec'd callback is only called when an element's subtree is attached or detached form the main document, which is a much lower frequency situation.

This is less powerful, but it is perhaps a good tradeoff to avoid killing custom elements with expensive callbacks?


comment: 2
comment_url: https://www.w3.org/Bugs/Public/show_bug.cgi?id=24866#c2
Anne wrote on 2014-03-17 12:18:02 +0000.

Note that the callbacks in DOM need to be updated to take several arguments to provide context for what actually happened. I haven't attempted that rewrite yet.

@treshugart
Copy link

If inserted and removed were to be added in lieu of attached and detached, then how would a component know when it is attached? One could call document.contains(this), but that wouldn't be ideal because it's the more common use case (boilerplate) and has 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.

@rniwa
Copy link
Collaborator

rniwa commented Mar 1, 2016

This issue was discussed during Jan F2F and will be resolved in the issue #362.

@rniwa rniwa closed this as completed Mar 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants