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

Re: [widgets-twi] window object

From: Scott Wilson <scott.bradley.wilson@gmail.com>
Date: Tue, 9 Feb 2010 15:05:16 +0000
Cc: cyril.concolato@telecom-paristech.fr, Robin Berjon <robin@berjon.com>, public-webapps <public-webapps@w3.org>
Message-Id: <87BBB244-6114-4241-808F-B077164F5B82@gmail.com>
To: marcosc@opera.com

On 9 Feb 2010, at 09:22, Marcos Caceres wrote:

> On Tue, Feb 9, 2010 at 9:54 AM, Cyril Concolato <cyril.concolato@enst.fr 
> > wrote:
>> Le 08/02/2010 13:29, Robin Berjon a écrit :
>>>
>>> On Feb 5, 2010, at 16:18 , Marcos Caceres wrote:
>>>>
>>>> On Thu, Feb 4, 2010 at 6:41 PM, Cyril Concolato<cyril.concolato@enst.fr 
>>>> >
>>>>  wrote:
>>>>>
>>>>> So I'm wondering how should the widget object be implemented in  
>>>>> a UA
>>>>> that does not support the window object ?
>>>>
>>>> Yeah, that's a tough one... the spec says:
>>>>
>>>> "For a widget instance, a user agent MUST expose a unique object  
>>>> that
>>>> implements the widget interface to author scripts."
>>>>
>>>> It does not give any guidance as to how the interface must be  
>>>> exposed.
>>>
>>> But then again, SVG supports the Window object (minimally defined in
>>> http://www.w3.org/TR/SVGMobile12/svgudom.html#dom__Window). So  
>>> just adding a
>>> widget field there ought to be straightforward.
>>
>> My mistake. I had not realized that. But again, the question is why  
>> put the
>> widget object on the window object, apart from it being a black  
>> hole. Why
>> not put it in the global object. What's wrong with that? It would  
>> easier to
>> specify. What's the benefit of using the window object?
>
> I don't think there is a way around this. Everything lives in the
> window: it is the top level scope. This is evident by running
> "<script>alert(this)</script>", which returns [object Window] or
> [object DOMWindow]. Changing this to have Widget as the top or as a
> shared top level scope would break code expecting to window object to
> be there. Also, it might not even be possible to have two objects be
> at the level scope at the same time.

In Wookie we just create the widget object in the global scope, and  
then add it as an attribute to the window object. Author scripts can  
access it either by "window.widget" or just plain "widget".

I wonder though - for authors what should we recommend if they want  
their widget to run unmodified in the most UAs?

S


Received on Tuesday, 9 February 2010 15:05:48 GMT

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