Changing [[Prototype]]

David Bruant bruant.d at gmail.com
Mon Dec 24 02:17:58 PST 2012


Le 24/12/2012 10:48, Anne van Kesteren a écrit :
> I thought I'd give a heads up as over on www-dom at w3.org we're
> discussing two cases where we likely need to change the prototype
> chain of objects: document.open() and methods that do the equivalent
> of document.adoptNode() (including that method itself):
>
> http://lists.w3.org/Archives/Public/www-dom/2012OctDec/thread.html#msg143
Thanks for the heads up!

> It seems ES6 has __proto__ which also allows modifying [[Prototype]]
> so presumably this is nothing particularly bad, although it is very
> ugly :-(
The ability to change the [[Prototype]] of an object is orthogonal to 
the __proto__ problem. If it's necessary for DOM objects to change the 
[[Prototype]] for backward-compat or security reasons, it can do so, I 
guess. __proto__ is about author being allowed to change the [[Prototype]].

One thing to keep in mind, under no circomstances an object with 
[[Extensible]]:false can have its [[Prototype]] changed. The solution is 
either to forbid the change to [[Extensible]]:false (by throwing when 
about to) or forbid changing the [[Prototype]].

David


More information about the es-discuss mailing list