Re: Simplifying element creation

On 10/06/2011 12:51 AM, Jonas Sicking wrote:

> It sounds to me like we're creating a JSON format for the DOM and
> making element.append accept the JSON format. This doesn't sound great
> to me. It basically sounds like too high level to fit enough use
> cases.

Just the .append part? I see no reason that Element.create couldn't tork 
in the same way to produce an element with a subtree.

> It seems better to have an API for creating a single element (with
> attributes and event handlers), and then let people combine calls to
> that to do their own JSON->DOM conversion.

It's not clear why that would be better given it is strictly a subset of 
this proposed functionality. Indeed it is almost identical except that 
one can't add child nodes to the created element.

> Possibly it would make sense for the function to take an additional
> string-argument is used to create a text node which is inserted as a
> child. But I don't think we should add complexity in the form of
> sometimes interpreting that string as a node-name and sometimes as a
> textnode value.

I agree that would be bad, but it seems quite possible to avoid that in 
the design.

Received on Thursday, 6 October 2011 08:41:49 UTC