Le 26/10/2012 22:56, Asen Bozhilov a écrit :
> I would like to define custom getter and setter for `__proto__`
> property:
>
> var obj = Object.defineProperty({}, '__proto__', {
> get : function () {return '__proto__ getter'},
> set : function (){return '__proto__ setter'}
> });
>
>
> console.log(obj.__proto__); //[object Object]
> console.log(obj.__proto__ = {}); //[object Object]
>
>
> I didn't find an engine which outputs the values in get and set.
On Firefox Aurora, I find:
"__proto__ getter"
"[object Object]"
> The idea behind my code is to reject the `__proto__` ability to change
> the internal [[Prototype]]
In conforming engines, 'delete Object.prototype.__proto__' will do the
job for all objects at the same time.
> Is the above behavior should be observed according ECMAScript 6?
It is not, but it's likely that no implementation perfectly conforms.
Take a look at
http://wiki.ecmascript.org/doku.php?id=strawman:magic_proto_property
According to this strawman, the output should indeed be
"__proto__getter" then "__proto__setter".
David
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss