Re: [DOM4]: Element.create

On Friday, September 16, 2011, Ian Hickson <ian@hixie.ch> wrote:
> On Thu, 15 Sep 2011, Anne van Kesteren wrote:
>> On Thu, 15 Sep 2011 20:07:51 +0200, Charles Pritchard <chuck@jumis.com>
wrote:
>> > On webapps, we discussed a helper method, "create", which might fit
well in
>> > DOM4.
>> > http://lists.w3.org/Archives/Public/public-webapps/2011JulSep/0707.html
>> >
>> > Element.create('img', {src: '...'}),
>>
>> I'm not sure what the second argument should be in terms of Web IDL. It's
>> basically an unconstrained dictionary, but we do not have that at the
moment.
>
> "object", and define how to process it in prose.
>
>
>> It's also unclear to me whether the second argument should set
>> properties or attributes.
>
> IMHO definitely content attributes. Setting properties seem like it would
> involve all kinds of complicated subtlties like setting order, how to
> handle properties like .innerHTML, etc.
>
> Are there good use cases for setting properties?

Being able to set onfoo event handlers.

While you can do that using strings, it's much better to be able to code
using code than using code-in-strings. The latter also looses scope chains
and creates bad scope chains for form elements.

But I do agree that it would be a pain to deal with any other IDL properies.

/ Jonas

Received on Saturday, 17 September 2011 00:14:46 UTC