[Harmony Proxies] Proposal: Property fixing
David Bruant
david.bruant at labri.fr
Fri May 13 02:09:11 PDT 2011
Le 13/05/2011 02:55, Rick Waldron a écrit :
> David,
>
> For clarification, can you give a working example (ie runable in FF
> nightly) of this:
>
> "Object.prototype.toString could return different
> things for DOM objects. This can certainly be implemented in pure
> ES.next with WeakMaps. "
Sure. Here is an example of what I was thinking:
https://gist.github.com/970223
I run it directly on the webconsole and it works like a charm (Tested on
latest FF nightly on Windows 7 64bits)
A couple of things to keep in mind:
- I have no idea which DOM "classes" people expect and what particular
values of [[Class]] are set for them.
- I do not create objects respecting the DOM interfaces (it shouldn't
make any difference, but tell me if you think it does)
- My sole purpose was to prove feasbility. I am aware that the solution
I show is suboptimal in several ways (especially the several
redefinitions of Object.prototype.toString)
- The same could have been achieved with arrays instead of weak maps,
but would have led to memory leaks.
- I assume the "environment setting" code to run in a fresh conforming
ES environment (ES5.1 + current implicit consensus on WeakMaps)
David
More information about the es-discuss
mailing list