operasoftware / dragonfly

Opera Dragonfly is a fully featured development and debugging tool integrated into the Opera browser.
http://www.opera.com/dragonfly/
Apache License 2.0
160 stars 48 forks source link

ES5 setters are shown as 'getter' in console log #91

Closed c69 closed 12 years ago

c69 commented 12 years ago

var a = { b: 1, get x () { return this.b; }, set z (v) { return (this.b = v); } }

When we inspect 'a' in console - we see:

[-] Object b 1 x getter z getter

hzr commented 12 years ago

This is by design, click "getter" to evaluate.

hzr commented 12 years ago

Sorry, read this too fast, this is clearly a problem. Reopening.

hzr commented 12 years ago

No, closing again. I can't find it in the spec, but when you specify only a setter, a getter is automatically created with the value undefined. This is what you see.

c69 commented 12 years ago

ok, but How can i inspect a setter then ?

rchl commented 12 years ago

Not sure what you mean by inspect a setter. I don't think you can obtain reference to the function that runs on setting value, if that's what you mean.

One might argue that 'getter' is a poor name for what not necessarily has to be a getter, in ecmascript sense. It could be a property that is just not 'trivial' to obtain and thus requires manual evaluation to get the value. Maybe we should rename 'getter' to 'fetch' or 'retrieve' for example.

chriskr commented 12 years ago

You can do a.__lookupSetter__("z") which returns the setter or Object.getOwnPropertyDescriptor(a, "z") which returns an object with configurable, enumerable, get and set.

c69 commented 12 years ago

Thanx for the tip, this works.