Subj : Re: Setter and Getter inherited from a prototype To : =?ISO-8859-1?Q?Georg_Maa=DF?= From : Brendan Eich Date : Mon Mar 17 2003 07:37 pm Georg Maaß wrote: > If my object "A" inherits a getter or setter for property "a" from the > prototype "B", assigning a value to this property does not really > replace the inherited behaviour by a own property of object "A". The > inherited getters and and setters on this property remain active. This is a bug, I'm surprised no one complained sooner. Sorry abou that -- it's filed as http://buttmonkey/bmo/show_bug.cgi?id=197940, and I'll fix it soon for 1.4a. > This is an unexpected behaviour. Is this intented? How can I throw > away such inherited setters and getters? I tried the delete operator, > but this was useless. The inherited getter is still active. You can't delete. If you need a workaround, save the delegating object's __proto__, set that property to null, override the prototype property, then restore __proto__. /be > > > > js> function A(){} > js> function B(){this.__defineGetter__('a',function(){return false;})} > js> A.prototype=new B; > [object Object] > js> a=new A; > [object Object] > js> a.a=6; > 5: TypeError: setting a property that has only a getter > js> delete a.a; > true > js> a.a=6; > 7: TypeError: setting a property that has only a getter > js> a.a > false > js> > js> a.hasOwnProperty('a'); > true > > > > .