You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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.
The text was updated successfully, but these errors were encountered:
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.
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.
The text was updated successfully, but these errors were encountered: