W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2013

RE: Convenient way to create element and set its attributes at once

From: François REMY <francois.remy.dev@outlook.com>
Date: Mon, 2 Dec 2013 20:25:25 +0100
Message-ID: <DUB405-EAS162CB835A8DCA39C64BBAA0A5EA0@phx.gbl>
To: "'Domenic Denicola'" <domenic@domenicdenicola.com>, "'Tab Atkins Jr.'" <jackalmage@gmail.com>
CC: "'Elliott Sprehn'" <esprehn@gmail.com>, "'Marat Tanalin | tanalin.com'" <mtanalin@yandex.ru>, <www-dom@w3.org>
± -----Message d'origine-----
± De : Domenic Denicola [mailto:domenic@domenicdenicola.com]
± Envoyé : lundi 2 décembre 2013 20:11
± À : Tab Atkins Jr.
± Cc : Elliott Sprehn; Marat Tanalin | tanalin.com; www-dom@w3.org
± Objet : RE: Convenient way to create element and set its attributes at once
± 
± From: Tab Atkins Jr. <jackalmage@gmail.com>
± 
± > 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.
Received on Monday, 2 December 2013 19:25:55 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:21 UTC