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

Re: Simplifying element creation

From: Anne van Kesteren <annevk@opera.com>
Date: Thu, 06 Oct 2011 10:46:27 +0200
To: "Jonas Sicking" <jonas@sicking.cc>
Cc: "www-dom@w3.org" <www-dom@w3.org>
Message-ID: <op.v2w9bpj164w2qv@cm-84.208.66.146.getinternet.no>
On Thu, 06 Oct 2011 00:51:09 +0200, Jonas Sicking <jonas@sicking.cc> 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.

How it too high-level? Inserting elements and text nodes is the 80/20 of  
the DOM. And providing a viable simple alternative to innerHTML seems like  
a major win.


> 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.
>
> 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'm not sure what complexity you see. The first argument of the array sets  
the local name, later arguments set its children (which can in turn be  
other arrays). To allow multiple elements to be inserted we will use  
varargs.


-- 
Anne van Kesteren
http://annevankesteren.nl/
Received on Thursday, 6 October 2011 08:47:00 GMT

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