RE: Convenient way to create element and set its attributes at once
François REMY <[email protected]>
| Newsgroups | gmane.comp.web.dom.general |
|---|---|
| Message-ID | <[email protected]> |
± -----Message d'origine----- ± De : Domenic Denicola [mailto:[email protected]] ± Envoyé : lundi 2 décembre 2013 20:11 ± À : Tab Atkins Jr. ± Cc : Elliott Sprehn; Marat Tanalin | tanalin.com; [email protected] ± Objet : RE: Convenient way to create element and set its attributes at once ± ± From: Tab Atkins Jr. <[email protected]> ± ± > HTML.h1 = function(...args) { return new HTMLHeadingElement("h1", ± > ...args); }; HTML.h1.prototype = HTMLHeadingElement.prototype; ± ± Seems OK, but why not just ± ± HTML.h1 = function(...args) { return new HTMLHeadingElement("h1", ...args); ± }; ± ± and don't call it with `new`? Having multiple constructors for the same ± prototype feels ... unusual ... Constructors do not need to be used with new, when done properly. That being said, Image vs HTMLImgElement is already a precedent.