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

Re: Getters establish own properties, or why is [NamedPropertiesObject] discouraged?

From: Garrett Smith <dhtmlkitchen@gmail.com>
Date: Fri, 24 Feb 2012 18:20:56 -0800
Message-ID: <CABZUbM1u+oNfOhKsQQOL3WoEzLEJRKNKKF3d3oXrc92XQa_RsA@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: public-script-coord@w3.org
On 2/24/12, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 2/24/12 1:05 PM, Garrett Smith wrote:
>> No, using getter/setter instead does not mean that the properties are
>> "own".
> Per current webidl spec, defining a "getter" or "setter" on the
> interface does mean the properties involved are own properties.  Please
> see the spec.
What implementation does that?

>> In fact, it is often the case where an object's getter or
>> setter resides on the prototype chain. For example, the style
>> property, in Gecko is a getter on the prototype chain:-
>> document.body.hasOwnProperty("style");.
> That's not a "getter" in the IDL.
I didn't say it was. That line of code shows that `document.body` does
not have an own `style` property. The reason for showing that is to
demonstrate that 1) The element has a style property, 2) that it is
not an /own/ property, and 3) that it is implemented as a getter, on
the prototype and not as a getter on the object itself.

> Try something more like this:
>    <body name="foo">
>    <script>
>      alert(document.getElementsByTagName("body").hasOwnProperty("foo"));
>    </script>
What's that supposed to show?
Twitter: @xkit
Received on Saturday, 25 February 2012 02:21:25 UTC

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