RE: Convenient way to create element and set its attributes at once
Domenic Denicola <[email protected]>
| Newsgroups | gmane.comp.web.dom.general |
|---|---|
| Message-ID | <15dd542548c74df28a58439957891b32@BN1PR05MB325.namprd05.prod.outlook.com> |
From: Tab Atkins Jr. <[email protected]> > It would be useful for HTML to do the same, so you could call "new HTML.div(...)" instead of "new HTMLDivElement(...)". This seems like a really cool plan. (Although of course ES6 modules would be better, but, no need to hold up the platform waiting for them... namespaces are fine in the meantime.) > It would also let us establish a one-to-one constructor to tagname correspondence, so "HTML.h1()" works instead of "HTMLHeadingElement('h1',...)". I guess it would not be a constructor in that case though, i.e. you'd do `var myH1 = HTML.h1()` instead of `var myH1 = new HTML.h1()`, since otherwise you would break the `new X instanceof X` invariant.