HTML5 spec. seems to unnecessarily ban strict mode event handlers
dhtmlkitchen at gmail.com
Thu Feb 3 14:16:28 PST 2011
On 2/3/11, Allen Wirfs-Brock <allen at 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.
> 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.
"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?
More information about the es-discuss