-
Notifications
You must be signed in to change notification settings - Fork 180
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
Extended custom element creation #419
Comments
Incremental DOM's current API does not support There are currently two options if you need to create such a custom element. Given a custom element definition: class MyList extends HTMLUListElement {
constructor() {
super();
}
}
customElements.define('my-list', MyList , { extends: "ul" });
elementOpen(MyList, key, statics);
...
elementClose(MyList);
function MyListConstructor() {
return document.createElement('ul', { is: 'my-list' });
}
elementOpen(MyListConstructor, key, statics);
...
elementClose(MyListConstructor); The second is a little inefficient in that it creates an extra object that gets thrown away immediately (when Incremental DOM uses |
The second case is actually a blocker, if we persist that extended custom element state. With the next patching the state is lost. |
Ah, it doesn't pick it up as a matching node. You can do: function MyListConstructor() {
return document.createElement('ul', { is: 'my-list' });
}
MyListConstructor.prototype.toString = function() {
return 'ul';
}; Unfortunately, there doesn't seem to be a way to distinguish this from a plain |
Actually, looking at it again, the If that is not the case, do you have an example where the element is not being reused? |
My bad, I overlooked that I should’ve passed the same function each render call. It works like a charm, thanks for your reply. |
For now
elementOpen
supports custom element tag names, but what if it's required to create custom element, extended from built-in?Like in this example from MDN:
That seems to be not implemented:
incremental-dom/src/nodes.ts
Line 70 in 9a78593
Is there any possible workaround or solution to that? Tricks in
notifications.nodesAdded
?Any hope that will ever get added?
The text was updated successfully, but these errors were encountered: