@@unscopable and event handlers

Ian Hickson ian at hixie.ch
Wed Sep 25 16:08:22 PDT 2013

On Wed, 25 Sep 2013, Allen Wirfs-Brock wrote:
> On Sep 25, 2013, at 3:02 PM, Jason Orendorff wrote:
> > 
> > Suppose I have:
> > 
> >    <p onclick="alert('hello')">
> > 
> > This creates new object environment records. (See the HTML spec, "When 
> > an event handler content attribute is set", step 6: 
> > <http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#event-handler-content-attributes>)
> > 
> > 1. I think the design intent of @@unscopable was that event handlers 
> > *would* be affected, but it doesn't seem to be specified that way, 
> > yet. Should ES6 factor anything differently to accommodate what HTML 
> > is trying to do there?
> I once tried to convince Hixie that he shouldn't try to tie into ES 
> spec. internal in that manner and that a better alternative would be to 
> express this as a code rewriting such as:
>     function makeEventHandler (__element__) {
>         with (Document)
>               with (__element__) 
>                    return function(event) {
>                         <<insert event handler code here >>
>                     };
>      }
> I didn't succeed.

Specifically, this was the conversation:

> Doing so would have decoupled the HTML spec. from the actual ES spec. 
> formalism and and instead couple it to the ES language semantics in an 
> edition independent manner.

I agree with the goal, but I don't think that defining things as a string 
transformation makes sense, for the reasons discussed in the bug above, 
primarily that it is hard to reason about exactly what the implications of 
a particular transform are.

The way we've been doing this for all the other specs is to provide 
explicit spec hooks, essentially a prose-level stable interface that one 
specification provides for other specifications to hook into. For example, 
see this in the HTML spec:


...which is then referenced by the Page Visibility specification. Or see 
this, which is referenced from HTML:


> Instead, at some point, the HTML spec. is going to have to do a set of 
> updates in order to bring it into alignment with new ES6 formalisms.

Happy to do that when it's appropriate; let me know.

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

More information about the es-discuss mailing list