Re: Simplifying element creation

On Tue, Oct 4, 2011 at 6:01 PM, Roland Steiner <rolandsteiner@google.com>wrote:

> On Wed, Oct 5, 2011 at 9:39 AM, Ojan Vafai <ojan@chromium.org> wrote:
>
>> Given ES6 spread, I don't think we need to allow NodeList or Array. Not
>> allowing arrays also means we avoid the issue that Roland brought up because
>> the first string in any array is an element name and not text and only the
>> first string in an array is an element name.
>>
>> For example:
>> foo.append('div'); // appends the string 'div' to foo as a text node
>> foo.append(['div']); // appends a div element to foo
>>
>
> That seems reasonable. Conversely, being strict about this means
>
> ['style', 'scoped']
>
> is not equivalent to <style scoped>, neither equivalent to
> <style>scoped</style>, but simply an error (that throws, I presume?).
>

What's the error? This would just be <style>scoped</style>. The attributes
and event objects are optional.


>
>
>
>> Element.create(['div', {}, {'onclick': 'return false;', 'onmousedown':
>> function() {}}]);
>>
>
> Probably this has been brought up before, but what prevents event handlers
> from being put together with regular attributes (which I'm sure people will
> try), by design or by error? E.g.,
>
> ['div', {'style': 'background-color: red'; color: white, 'onclick':
> 'doThaClick()'}]
>
> Conversely, why the requirement to have 2 different entries for those?
> Conceptually, when writing <div style="color:red" onclick="clicky()"> there
> isn't a distinction either.
>
>
> Cheers,
>
> - Roland
>
>
>

Received on Wednesday, 5 October 2011 01:08:45 UTC