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

Re: Simplifying element creation

From: Ryosuke Niwa <rniwa@webkit.org>
Date: Mon, 14 Nov 2011 16:16:29 -0800
Message-ID: <CABNRm63JKLon3afLpi0qMNxOcnQY+hq=61yD=bHs3=vHYuzj9A@mail.gmail.com>
To: Dominic Cooney <dominicc@chromium.org>
Cc: Anne van Kesteren <annevk@opera.com>, "www-dom@w3.org" <www-dom@w3.org>
On Sun, Nov 13, 2011 at 9:06 PM, Dominic Cooney <dominicc@chromium.org>wrote:

> On Sun, Nov 13, 2011 at 7:41 PM, Ryosuke Niwa <rniwa@webkit.org> wrote:
>>
>>  to
>>     var table = Element.create('table', {}, [Element.create('tbody')]);
>> ...
>>     for (var i = 0; i < labels.length; i++) {
>>         table.childNodes[0].append(
>>             Element.create('tr', {}, [
>>                 Element.create('td', {}, [labels[i]]),
>>                 Element.create('td', {}, [
>>                     Element.create('span', {'class': 'bar', 'style':
>> 'width: ' + <same expression> + '%'}),
>>                     Element.create('span', {'class': 'value-container'},
>> [values[i]])])
>>                 ])
>>         );
>>     }
>>     element.appendChild(table);
>>
>> My only complain will be that I had to serialize style attribute. I want
>> to be able to do:
>> Element.create('span', {'class': 'bar', 'style': {'width': <same
>> expression> + '%'}})
>> instead.
>>
>
> Instead of carving out an exception for 'style', could we optimistically
> assume that CSSOM will specify a convenient way to create CSSRule instances
> from JavaScript, and allow style: e where e results in a CSSRule?
>

You mean CSSStyleDeclaration? That's an interesting idea.

- Ryosuke
Received on Tuesday, 15 November 2011 00:17:17 GMT

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