@@unscopable and event handlers

Allen Wirfs-Brock allen at wirfs-brock.com
Wed Sep 25 15:45:05 PDT 2013

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

In this case, explicitly using a with statement would have automatically triggered and @@unscopable with semantics we define.  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.

> 2. Will this cause document[@@unscopable] to be retrieved and
> examined? If so, that can trigger arbitrary user code, right? Is that
> OK?

If document[@@unscopable] is defined as non-configurable the users should be able to associate code with its access.


More information about the es-discuss mailing list