W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2015

Re: Defining a constructor for Element and friends

From: Ryosuke Niwa <rniwa@apple.com>
Date: Tue, 13 Jan 2015 10:18:11 -0800
Cc: Boris Zbarsky <bzbarsky@mit.edu>, Anne van Kesteren <annevk@annevk.nl>, WebApps WG <public-webapps@w3.org>, "www-dom@w3.org" <www-dom@w3.org>
Message-id: <2E56F409-EF53-4454-9635-C43D8D127E12@apple.com>
To: Domenic Denicola <d@domenic.me>

> On Jan 13, 2015, at 9:25 AM, Domenic Denicola <d@domenic.me> wrote:
> 
> From: Boris Zbarsky [mailto:bzbarsky@mit.edu] 
> 
>> But it also means that user-space code that has to create an HTML element generically now has to go through document.createElement instead of being able to do |new HTMLElement("a")|, right?
> 
> That seems totally fine to me though. The idea of a string-based factory for when you don't know what constructor you want to use has precedent all over software design.

I agree. It's unusual for a constructor of a super class to automatically instantiate an arbitrary subclass based on its arguments. And we usually solve that convenience problem by introducing a factory class/function.

- R. Niwa
Received on Tuesday, 13 January 2015 18:18:45 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:27:25 UTC