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

Re: Should events be preferably sent to the Window or the nearest object?

From: Ian Hickson <ian@hixie.ch>
Date: Thu, 20 Mar 2014 15:33:19 +0000 (UTC)
To: Mounir Lamouri <mounir@lamouri.fr>
cc: public-webapps@w3.org
Message-ID: <alpine.DEB.2.00.1403201530250.21227@ps20323.dreamhostps.com>
On Fri, 21 Mar 2014, Mounir Lamouri wrote:
> 
> I would love to gather the opinion of public-webapps on a discussion 
> Hixie and I had for two different APIs recently: if an array |foo| can 
> change, should the change event be fired on its parent or the window 
> (its grandparent)? The two cases we discussed with Hixie were 
> navigator.languages and screen.orientation for which Hixie thinks the 
> change events should be fired on the window so developers can do <body 
> onlanguagechange="..." onorientationchange="..."> but I feel that having 
> the change event sent on the parent would make things more 
> self-contained.
> 
> I would love to hear people's opinion on this.
> 
> (Note: sending an orientationchange event to the window object would 
> have other implications because there is a proprietary API that does 
> that but this is entirely orthogonal.)

To be clear, my opinion is just that we should be consistent. If the event 
is related to the Document, then we should fire it at the Document. If 
it's related to the <html>, we should fire on the <html>. Some objects are 
already EventTargets, including many new objects. I'm just saying that for 
existing objects that aren't EventTargets, and for which events have 
historically been sent to the Window, we should continue to send events to 
the Window, so that we don't end up sending some events to the object and 
some to the Window. In the case of Navigation, "online" and "offline" 
events go to the Window. In the case of Screen, "resize" and "scroll" 
events go to the Window. So it makes sense to put new events there too.

IMHO.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Thursday, 20 March 2014 15:33:41 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:14:22 UTC