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

Re: [webcomponents] Considering declarative event handlers

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Tue, 07 Feb 2012 15:05:14 -0500
Message-ID: <4F3183FA.4070605@mit.edu>
To: public-webapps@w3.org
On 2/7/12 2:41 PM, Dimitri Glazkov wrote:
> <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>

This looks an awful lot like what XBL does (it uses <handler> elements 
for this).

People had some issues with this, which is why XBL2 had moved to a 
single script blob that just set things like the onclick attribute.

I assume you've looked into what these issues were?  At least ask hyatt 
and hixie, please.

> * It's declarative and intuitively logical
> * The script does not have to run (or even compile) until event fires
> * The author does not need to imperatively go find the element in the
> tree to attach an event handler to it

#3 is achievable with other approaches (e.g. just having a <script> that 
runs with "this" set to the element in question or something).

#2 is true, but would be equally true with:

   this.onclick = function() { .... }

I think.  The only thing the UA would have to do there is syntax-check 
the function, which I think is desirable to do anyway for error 
reporting purposes.

-Boris
Received on Tuesday, 7 February 2012 20:09:03 GMT

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