W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2013

Re: window.event and Event.srcElement

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Mon, 25 Mar 2013 15:00:50 -0400
Message-ID: <51509EE2.9030005@mit.edu>
To: David Bruant <bruant.d@gmail.com>
CC: public-webapps@w3.org
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 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:58 GMT