- From: Dimitri Glazkov <dglazkov@google.com>
- Date: Tue, 2 Aug 2011 09:09:54 -0700
- To: Roland Steiner <rolandsteiner@google.com>
- Cc: Jonas Sicking <jonas@sicking.cc>, Maciej Stachowiak <mjs@apple.com>, Alex Russell <slightlyoff@google.com>, WebApps WG <public-webapps@w3.org>
On Tue, Aug 2, 2011 at 1:27 AM, Roland Steiner <rolandsteiner@google.com> wrote:
> 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).
I am not sure it will be easier but it does seem that it would be more
natural to an author to write:
var foo = new FooButton();
than:
var foo = Element.create('x-foo-button').
:DG<
>
>
>> 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.
>
>
> Cheers,
>
> - Roland
>
>
Received on Tuesday, 2 August 2011 16:10:18 UTC