Re: Simplifying element creation

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 UTC