-
Notifications
You must be signed in to change notification settings - Fork 382
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
[idea] making builtin elements more like custom elements #785
Comments
As mentioned in #550, the main arguments against Speaking as someone who has used a lot of hacks to work around otherwise-unassailable problems over the years, I see this as something that would be used in much the same way. When you find a lot of dependencies all using this technique to work around their own otherwise-unassailable problems then you can find yourself deep in performance issues. Imagine thousands of nodes being connected at once, each one triggering your function, which adds more nodes, which triggers more connected callbacks. Now imagine your dependencies doing the same thing in addition. This kind of impact is detrimental to the web, even if you have good use cases and intentions. Besides the performance implication, this suggestion renders closed shadow trees nearly pointless. Although it is easy to override |
The way built-in elements work is similar to the following code: class SomeBuiltinElement {
connectedCallback() {
// do something
}
}
// This call causes the system to store SomeBuiltinElement.prototype.connectedCallback for later use.
customElements.define('somebuiltinelement', SomeBuiltinElement);
// But, it's not accessible to users.
delete SomeBuiltinElement.prototype.connectedCallback; |
We're not going to do this due to performance issues but also because browser engine code needs to update its internal states prior to start invoking JavaScript. It's simply not attainable to make all builtin elements' implementation work with the proposed API. It's possible we can add some mutation observer observation records for when a node is connected or disconnected though. |
A much lower level api like the one described in whatwg/dom#533 should be sufficient. |
Ah, yeah, I think that'd be nice! |
If you imagine builtin elements as having the same underlying building blocks as custom elements (i.e. the Web Manifesto explains builtins, and we can do the same stuff in custom elements), then one would think that we could do the following:
I think it'd be nice if this were possible.
This would make it simple to implement a lot of stuff. For example a
childConnectedCallback
(described in #550) could be easy:Would it be easy to move existing logic of builtin elements into lifecycle methods without breaking existing sites?
If we wouldn't want to do this, why not?
The text was updated successfully, but these errors were encountered: