just because I wanted to test which version/engine of V8 or other browsers behaves like that ... most recent, but it hasn't been like this before and I believe before was correct, now it's just confusing. Here many browsers under test: http://browsershots.org/http://www.3site.eu/dp.html
green means instances have no problems defining properties, red means these have problems with inherited non writable properties. This looks like a `with(instance) property = value` problem to me, where the property is retrieved through the __proto__ chain rather than assigned to the instance ... unexpected, IMHO On Tue, Nov 6, 2012 at 9:44 AM, Andrea Giammarchi < [email protected]> wrote: > I found this behavior quite hilarious and I wonder if this is expected. > It is also new somehow 'cause node.js < 0.8.1 wasn't behaving like this. > > I am talking about the fact if a prototype has a non writable and not > configurable property the instance will partially inherit this behavior so > that obj.prop = value will fail but not Object.defineProperty(obj, "prop", > {value:value}); > > This is true **only** with non writable, 'cause non configurable will > still be OK. Here the code to test what I am talking about: > > function setAndVerify(self) { > var name = self.constructor.name; > self.test = true; > if (!self.test) { > console.log(name + " no direct set"); > Object.defineProperty(self, "test", {value: true}); > if (!self.test) { > console.log(name + " not even configurable"); > } > } > } > > function CEW() { > setAndVerify(this); > } > Object.defineProperty( > CEW.prototype, "test", { > configurable: true, > enumerable: true, > writable: true, > value: false > } > ); > new CEW; > > function EW() { > setAndVerify(this); > } > Object.defineProperty( > EW.prototype, "test", { > configurable: false, > enumerable: true, > writable: true, > value: false > } > ); > new EW; > > function E() { > setAndVerify(this); > } > Object.defineProperty( > E.prototype, "test", { > configurable: false, > enumerable: true, > writable: false, > value: false > } > ); > new E; > > The output will be E no direct set > > ... can anyone be so gentle to explain me this ? I would rather expect > both console.log messages at this point; as it is looks simply partially > broken behavior. Apologies if already discussed, couldn't find it. > > br >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

