W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2012

Re: [webcomponents] Considering declarative event handlers

From: Charles Pritchard <chuck@jumis.com>
Date: Tue, 07 Feb 2012 12:43:24 -0800
Message-ID: <4F318CEC.1000302@jumis.com>
To: Dimitri Glazkov <dglazkov@chromium.org>
CC: public-webapps <public-webapps@w3.org>
On 2/7/2012 11:41 AM, Dimitri Glazkov wrote:
> Folks,
>
> To make Web Components more usable, I would like to consider providing
> a way to declare event handlers in markup. As I look over the use

> <element name="x-tab-manager">
> <template>
> <div class="container">
> ...
> <div class="overflow">
>      <script event="click">
>          // "this" is the parent div element.
>          // "event" is the current event object.
>          if (event.target.className != 'more')
>              return;
>          if (this.moreOpened)
>              this.closeMore();
>         ...
>      </script>
> </div>
>
> ...
>
> </div>
> </template>
> </element>

> The cons are:
> * It's a new syntax
> * It doesn't allow to close over the event handler code, which is a
> common way to manage variable scoping in JS.
>
> I would appreciate any thoughts, ideas, or results of existing
> research on this. I am sure someone had thought about this harder and
> longer than I did.

How about setting it up as a different script type as well.
<script type="text/javascript+click">

That may be a horrible idea. So lets focus on the concern.
I'd like to be able to embed things like this in an HTML page and have 
them not break the page for browsers that don't support the template tag.

This script could pop up an error onload about how event doesn't have 
any attributes. Possibly, anyway.

-Charles
Received on Tuesday, 7 February 2012 20:46:27 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:50 GMT