Closed rictic closed 1 year ago
@rictic is this new? or something to do with SSR?
i was always under the impression if you try new up an element, you'll get an illegal constructor error.
class Foo extends HTMLElement {}
const f = new Foo(); // TypeError: Illegal constructor
i must be missing something though so probably just need an example
Not new, just obscure and rarely used
That example doesn't work because you can't new an HTMLElement subclass without giving it a tagname.
Simple demo: https://lit.dev/playground/#gist=a8f14e9b45ccaf9b91efcf232238451e
oh wow TIL!
has that always been a thing? i always assumed it was just impossible to new up such a class.
thanks for the explanation :D
Yeah, I believe it's always been a thing, since at least CE v1. I have no recollection (and don't think I ever understood really) how CE v0 handled constructors though
They may be constructed directly, they just usually aren't.