W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2011

Re: Simplifying element creation

From: James Graham <jgraham@opera.com>
Date: Thu, 06 Oct 2011 10:41:19 +0200
Message-ID: <4E8D69AF.9040404@opera.com>
To: www-dom@w3.org
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:08 GMT