Re: window.event and Event.srcElement

On 3/25/13 2:47 PM, David Bruant wrote:
> For the latter case, a scoping trick might work. In essence, on* code
> could run within a scope "located" between the code scope and the global
> scope.

It already does: the scope is the element, with some more complications 
as to what's on the scope chain above that.

We could complicate the scoping setup for event handlers even more, of 
course.  Would any UAs actually be willing to implement that (given that 
e.g. Chrome doesn't even implement the current, simpler, scoping setup 
sanely)?

> For the former case, things cannot be as easy as naively inserting an
> intermediate scope, because the function definition is somewhere else,
> but maybe we can get away with an equivalent trick. Thoughts?

I can't see any equivalent tricks given the scoping rules in JavaScript.

Basically, either UAs that currently implement window.event remove it or 
it's clearly required for web compat and hence needs to be specified so 
other UAs can implement it.  I don't see any other sane options; do you?

>> A brief look at stackoverflow will show that this is something authors
>> run into a lot.  And that's just the ones that are bothering to test
>> in multiple browsers.
>  From what you've seen is it the on* case?

The cases I've seen on stackoverflow are the onclick="something()" and 
then the "something" uses bareword "event".

>> If you want specific site examples www.ocn.ne.jp (on "mobile" only,
>> natch, thanks to only testing in WebKit) is the most recent one I came
>> across.
> Is it the on* case? (how do you test for "mobile only"?)

It's using event handlers, yes.  You test for "mobile only" by loading 
the site in Firefox on some desktop platform and Firefox on Android and 
observing that the site is UA-sniffing and sending different content, 
and that the site sent to desktop browsers works in Firefox but the site 
sent to "mobile" browsers does not.

-Boris

Received on Monday, 25 March 2013 19:01:19 UTC