I'm writing a JSX factory for vanilla JS, but I can't seem to get customized builtins to work.
If I define a
customElements.define('x-hi', class extends HTMLElement { })
I can just
document.createElement('x-hi')
to get an instance, how can I get an instance of this :-
customElements.define('x-hello', class extends HTMLButtonElement { }, { extends: 'button' })
You can also do it with normal custom elements, but you should use
document.createElement
as the custom element may be defined later on in the code.You're probably doing something like this in your factory:
When setting
is
tox-hello
on an already createdHTMLButtonElement
, you can't change it's prototype to have it become aHello