W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2012

[WebIDL] Feedback on getter and setter attribute algorithms

From: David Bruant <bruant.d@gmail.com>
Date: Sun, 08 Jan 2012 01:20:47 +0100
Message-ID: <4F08E15F.4000106@gmail.com>
To: public-script-coord@w3.org
Hi,

Both attributes getter and setter algorithms [1] do the following:
1) Let O be the result of calling ToObject on the /this/ value.
2) Throw a TypeError if the attribute was not defined with LenientThis
and O is not "a platform object that implements the interface on which
the attribute was declared"

Under these conditions, I wonder if the ToObject is really useful. In
the case /this/ is a primitive value different than undefined or null,
it will create an object based on the value. If the attribute is not
declared with [LenientThis], it will throw a TypeError. It won't with
the [LenientThis], but the attribute value will relate to an object that
can't be reached anymore (since the object is created internally and not
exposed to the outside world).

One idea would be that instead of the first "let O = ToObject(this)", a
TypeError could be thrown whenever /this/ is not of type Object (ES5.1 -
8.6 definition).
The difference in semantics is that an error is thrown for all primitive
values (instead of just undefined and null) for [LenientThis]
attributes. I can only see this as a good thing since I can see a use
case for using primitive values as /this/.

Is there some backward compatibility concern that could prevent this change?

David

[1] http://dev.w3.org/2006/webapi/WebIDL/#es-attributes
Received on Sunday, 8 January 2012 00:21:18 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:05 UTC