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

Re: Simplifying element creation

From: Roland Steiner <rolandsteiner@google.com>
Date: Wed, 5 Oct 2011 11:41:21 +0900
Message-ID: <CACFPSpiy=TpzYDhNxM_zUmXL_Aj852YOQAq7S86mdHawT2Qv4w@mail.gmail.com>
To: Ojan Vafai <ojan@chromium.org>
Cc: Dominic Cooney <dominicc@chromium.org>, Anne van Kesteren <annevk@opera.com>, "www-dom@w3.org" <www-dom@w3.org>
On Wed, Oct 5, 2011 at 10:07 AM, Ojan Vafai <ojan@chromium.org> wrote:

> 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.
>

>From arv's mail:

On Wed, Oct 5, 2011 at 9:06 AM, Erik Arvidsson <arv@chromium.org> wrote:

> [...]
>
ElementPattern :
>  '[' TagName ( ',' Attrs? ( ',' EventHandlers? (, Pattern)* )? )? ']'
>

I read this that you can have child-patterns only if you also specify Attrs
and EventHandlers, or at least commas for them, e.g., ['div', , , 'text']
(intentional?)


The Text production creates a Text node
>
> The ElementPattern creates an Element with the given tag name, attribtues,
> event handlers and its child nodes are provided by the rest patterns.
>
> For example:
>
> element.append('Hello', ['b', null, null, 'world'])
>

Otherwise the 'null's in above example also wouldn't be necessary.

OTOH, a pattern

'[' TagName (',' Attrs)? (',' EventHandlers)? (',' Pattern)* ']'

would lead to some potential amount of ambiguity, at least between Attrs and
EventHandlers (because both are just dicts), no?


Cheers,

- Roland
Received on Wednesday, 5 October 2011 02:42:06 GMT

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