W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2011

Re: Element.create(): a proposal for more convenient element creation

From: Maciej Stachowiak <mjs@apple.com>
Date: Mon, 01 Aug 2011 23:14:52 -0700
Cc: WebApps WG <public-webapps@w3.org>
Message-id: <A32B17E6-11A6-4114-85B1-3062A2252B11@apple.com>
To: João Eiras <joao.eiras@gmail.com>

On Aug 1, 2011, at 8:36 PM, João Eiras wrote:

> On , Ian Hickson <ian@hixie.ch> wrote:
> 
>> On Mon, 1 Aug 2011, Ryosuke Niwa wrote:
>>> On Mon, Aug 1, 2011 at 6:33 PM, Maciej Stachowiak <mjs@apple.com> wrote:
>>> >
>>> > In an IRC discussion with Ian Hickson and Tab Atkins, we can up with
>>> > the following idea for convenient element creation:
>>> >
>>> > Element.create(tagName, attributeMap, children�)
>>> 
>>> Can we alternatively extend document.createElement?  Or was this
>>> intentionally avoided to associate new elements with documents?
>> 
>> We could, but I'd much rather have the shorter name, personally. Having
>> the name be so long really makes that API unusable.
>> 
> 
> However, Nodes need a ownerDocument, and that needs to be supplied, even if optionally. Doing document.createElement implies the document, Element.create does not.

The intent is that it supplies the Window's current Document. It's true that sometimes you need to make a node for another Document, sometimes even one that lacks a namespace, but that's a sufficiently specialized case that it does not really need a convenience shortcut.

Regards,
Maciej
Received on Tuesday, 2 August 2011 06:15:30 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:46 GMT