W3C home > Mailing lists > Public > public-html@w3.org > September 2009

Re: WebIDL

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Sat, 26 Sep 2009 02:31:06 -0400
Message-ID: <4ABDB52A.1060805@mit.edu>
To: Yehuda Katz <wycats@gmail.com>
CC: public-webapps@w3.org, HTML WG <public-html@w3.org>, es-discuss <es-discuss@mozilla.org>
On 9/26/09 2:05 AM, Yehuda Katz wrote:
> So this extension effectively converts a readonly attribute to a
> writable one? Talk about confusing. And this isn't true about the same
> attribute in non-ES contexts?!

Replaceable is sort of weird.  In some ways, for a readonly attribute, 
one can think of it in ES terms as follows: the object's prototype has a 
property with that name and a [[Get]] that does something interesting. 
But trying to set the property on the object sets it on the object 
itself (and thus shadows the thing on the prototype).  Implementation 
behavior is not exactly consistent in terms of this interpretation, though.

For example, try putting this into a browser url bar:

javascript: alert(window.self); var self = 5; alert(window.self); delete 
window.self; alert(window.self)

In Gecko and Safari I believe you should get window, 5, window for the 
alerts.  I think in Chrome you get window, 5, 5.  In Opera you get 
window, window, window in my testing...  Note that none of them do what 
_usually_ happens when one tries to set a property declared as readonly 
in the idl, which is that an exception is thrown.

I hope everyone agrees that [replaceable] use should be kept to an 
absolute minimum...  it's a wacky weird thing largely necessitated by 
the fact that global variables in ECMAScript are in fact just named 
properties of the global object and that in the case of the web the 
global object happens to come with a slew of predefined properties, some 
of them readonly.  If their non-writability were enforced in the usual 
way (by throwing on attempts to set), then doing things like |var top| 
at the toplevel of a script would throw.  You can still run into trouble 
if you do things like:

   var Array = 5; alert([] instanceof Array);

but at least the various non-DOM properties on the ECMAScript global 
object don't have names that tend to collide with script authors' 
variable names..

> Which imposes a requirement on ECMAScript that such conversions be
> defined and possible. This is not always (or even often) possible.

I would hope the conversion process is allowed to throw in such 
situations.  Is that not the case?

-Boris
Received on Saturday, 26 September 2009 06:31:52 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:16:49 GMT