W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2011

Re: Element.create(): a proposal for more convenient element creation

From: Roland Steiner <rolandsteiner@google.com>
Date: Tue, 2 Aug 2011 17:27:21 +0900
Message-ID: <CACFPSpiJXv8PZ=d=fYVtXXD08SV5Qj8gB1Y8QrrK2aPFCLD0zQ@mail.gmail.com>
To: Jonas Sicking <jonas@sicking.cc>
Cc: Maciej Stachowiak <mjs@apple.com>, Alex Russell <slightlyoff@google.com>, WebApps WG <public-webapps@w3.org>
On Tue, Aug 2, 2011 at 4:36 PM, Jonas Sicking <jonas@sicking.cc> wrote:
> This doesn't explain why a factory method is better than explicit
> constructors though? The above could be written as
> new HTMLParagraphElement(null, "foo", ...);

It's not a general use case, but at least when it comes to XBL-like
components, having a factory method that does all the lookup and
binding behing the scenes probably is easier to implement than hooking
a constructor (FWIW).

> However I'm not sure what to do in situations where we don't have an
> explicit interface for an element, such as both <ins> and <del> both
> using HTMLModElement, and the long list of elements which only use
> HTMLElement as interface. cc'ing Alex Russel who is often a strong
> advocate for constructors over factory functions and who might have
> thought about this problem.


- Roland
Received on Tuesday, 2 August 2011 08:28:05 UTC

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