Re: Defining a constructor for Element and friends
Ryosuke Niwa <[email protected]>
| Newsgroups | gmane.comp.web.dom.general,gmane.org.w3c.webapps |
|---|---|
| Message-ID | <[email protected]> |
> On Jan 13, 2015, at 9:25 AM, Domenic Denicola <[email protected]> wrote: > > From: Boris Zbarsky [mailto:[email protected]] > >> 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