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

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

From: Dimitri Glazkov <dglazkov@google.com>
Date: Mon, 1 Aug 2011 20:29:49 -0700
Message-ID: <CADh5Ky364H0zKdUO_m0ujdUb9nBPWVkztOrt4u8gkU=QDZtpgg@mail.gmail.com>
To: Ian Hickson <ian@hixie.ch>
Cc: Maciej Stachowiak <mjs@apple.com>, WebApps WG <public-webapps@w3.org>
On Mon, Aug 1, 2011 at 6:43 PM, Ian Hickson <ian@hixie.ch> wrote:
> On Mon, 1 Aug 2011, Maciej Stachowiak wrote:
>>    Creates an element with the specified tag, attributes, and children.
>>    tagName - tag name as a string; by default it does "smart" selection
>> of SVG, HTML or MathML namespace. Authors can also use an html: svg: or
>> mathml: prefix to override these defaults.
> I'd suggest just always defaulting to HTML and requiring "svg:" and
> "mathml:" prefixes for those namespaces. That makes code easier to read
> (it's obvious what's going on, and you won't accidentally use elements
> from the wrong namespace). It also makes forward-compatibility easier (we
> don't have to worry about adding new elements to the list and what that
> will do to future legacy UAs).
>> (And further, you can use xmlns in attribute map to use a custom
>> namespace.)
> I wouldn't bother supporting the "xmlns" attribute in this API, but I
> don't feel strongly about this.
>>    attributeMap - JS object-as-dictonary or whatever dictionary type is
>> appropriate to the language, or null for no attributes
> Optional attribute, too.
>>    children� - veridic parameter, can include nodes, strings, or arrays.
>> Strings are converted to text nodes. Arrays are unpacked and treated as
>> lists of nodes/strings. Array support is for cases where you want to
>> have a call-site that may take a veriable-length list, with possible
>> prefix and suffix.
> Also optional.
> So you could also do:
>   var div = Element.create('div');

This is all pretty cool.

Received on Tuesday, 2 August 2011 03:30:14 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:34 UTC