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

Re: window.event and Event.srcElement

From: David Bruant <bruant.d@gmail.com>
Date: Mon, 25 Mar 2013 21:36:21 +0100
Message-ID: <5150B545.7080908@gmail.com>
To: Boris Zbarsky <bzbarsky@MIT.EDU>
CC: public-webapps@w3.org
Le 25/03/2013 20:00, Boris Zbarsky a écrit :
> 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.
I wasn't aware of that, but I see it now. Step 6 of:
http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#event-handler-content-attributes
(Lexical Environment Scope stuff)

> 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)? 
Any info on why they don't implement the spec scoping rules?
Is it going to be a case of de-facto standard too?

>> 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?
Only an insane option. Sharing as food for thoughts:
when about to call a function from an eval'ed on* attribute string, 
change the function's [[Scope]] to contain an extra scope with an 
"event" variable. Restore the [[Scope]] to its original value when the 
frame is dropped.
But of course, as soon as I talked about changing [[Scope]], I 
definitely fell in the "insane" category as I warned :-/

Since that case apparently requires window.event, no need to add extra 
work on on* scoping, I guess.


>>> 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.
Now I realize my question was stupid...

David
Received on Monday, 25 March 2013 20:36:51 GMT

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