W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2011

Re: HTML5 spec. seems to unnecessarily ban strict mode event handlers

From: Allen Wirfs-Brock <allen@wirfs-brock.com>
Date: Thu, 3 Feb 2011 15:32:05 -0800
Cc: EcmaScript <es-discuss@mozilla.org>, public-script-coord@w3.org
Message-Id: <CD45BA0D-DB67-4CC8-8034-553829C60A7C@wirfs-brock.com>
To: Garrett Smith <dhtmlkitchen@gmail.com>
Regarding the call language, it would probably be best if it was described in terms of invoking the [[Call]] internal method of the handler's function object.  However, that might be unnecessary if if the WebIDL ECMASCript binding makes it clear that the effect of invoking the call method of the Function interface is defined in terms of [[Call]].

We may have clashing spec. terminology here but I think the intent seems clear enough.

Allen



On Feb 3, 2011, at 2:16 PM, Garrett Smith wrote:

> On 2/3/11, Allen Wirfs-Brock <allen@wirfs-brock.com> wrote:
>> I was browsing Kangax's strict mode test result page
>> (http://kangax.github.com/es5-compat-table/strict-mode/ ) and I noticed that
>> he listed the recognition of a use strict directive of a event handler as a
>> "non-standard" feature that he tests for.
> 
> javascript: void(document.body.setAttribute("onclick", "'use
> strict;'\nalert(this);")); alert(document.body.onclick);
> 
>> 
>> To be sure, I checked the event handler section of the  HTML5 spec
>> (http://dev.w3.org/html5/spec/Overview.html#event-handler-attributes) and to
>> my surprise I discovered that it specifies the creation of the handler
>> function in a manner that, at first glance, seems to explicitly cause the
>> presence of a use strict directive to  be ignored.  Essentially it seems to
>> specify that event handlers specified using the event handler attribute are
>> never executed in ECMAScript 5 strict mode.  I don't know whether or not
>> this was intentional, but it certainly seems wrong.  The "strictness" of an
>> ECMAScript function is an internal and local characteristic of the function.
>> For a ECMAScript host to say that a use strict directive is ignored is
>> really no different  from saying that IfStatements or any other
>> syntactically valid element of a FunctionBody will be ignored.
>> 
>> The HTML5 spec. get into this trouble because of the way it uses the
>> abstract operation for creating function objects defined by section 13.2 of
>> the ES5 specification
> 
> HTML 5 also specifies that the function's `call` callback is called
> when in fact that does not happen at all.
> <http://dev.w3.org/html5/spec/Overview.html#event-handler-content-attributes>
> 
>  "When an event handler's Function object is invoked, its call()
> callback must be invoked with one argument, set to the Event object of
> the event in question."
> 
> Instead, it should say something like when the event handler is
> invoked, the callback function is called.
> 
> And to add to that D3E should say (and it has been agreed upon) that
> the `this` value (cntext) for callbacks oef event handlers is set to
> be the current target object.
> 
> Sprruy, I have only scanned and skimmed cause I'm too damn lazy :-D.
> But would there be any problems with doing things like that, Allen?
> -- 
> Garrett
Received on Friday, 4 February 2011 14:11:57 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:03 UTC