-
Notifications
You must be signed in to change notification settings - Fork 490
[v1] consistent constructor #595
Comments
I think the issue you're experiencing is that Subclassing I know there's currently still unresolved contention about |
I've probably badly explained the issue. Beside // create the class
class MyA extends HTMLAnchorElement {}
// define its name
customElements.define('my-a', MyA);
// and fail ...
document.body.appendChild(new MyA); If I do the same with the patched class MyElement extends HTMLElement {}
customElements.define('my-el', MyElement);
document.body.appendChild(new MyElement); // OK Since I see that also |
@WebReflection Ahh, ok, that makes perfect sense. I just submitted a preliminary PR (#596) adding support for customised built-ins. It definitely needs more testing and some cleanup, but it's something that can hopefully get this started. I'm not sure the plans @justinfagnani has here, though. Would be good to get his thoughts, too. |
Extending other built-ins besides |
This issue was moved to webcomponents/custom-elements#49 |
It seems like it's possible to
class MyElement extends HTMLElement {}
and thendocument.body.appendChild(new MyElement)
after defining the element throughcustomElements.define('my-element', MyElement)
.However, if I try to do the same, using
{extends: ...}
or not, I cannot create new custom elements in the same way.I wonder if it's in the pipeline to monkey-patch all HTML constructors like it's done already only for few of them, or if the usage of
new CustomElement
instead ofdocument.createElement('a', {is: 'my-a'})
will be discourage due polyfill limits (I personally wouldn't polyfill every DOM methods that might accept a generic node as one of its arguments).Thanks for any sort of clarification.
The text was updated successfully, but these errors were encountered: