[Harmony Proxies] Proposal: Property fixing

David Bruant david.bruant at labri.fr
Thu May 12 17:12:07 PDT 2011

Le 13/05/2011 01:20, Cameron McCormack a écrit :
> Tom Van Cutsem:
>> invariants that are enforced:
>>> - unconfigurable [[Class]] (Object or Function, respectively)
> Web IDL requires [[Class]] to take on values other than these two, for
> example it should be "HTMLDivElement" for an HTMLDivElement object.  I
> have a feeling that the web requires this, as opposed to just having a
> custom toString function.
> http://google.com/codesearch?q=Object.prototype.toString.call+lang:javascript
> brings up some libraries that use Object.prototype.toString on DOM
> objects.
> Is it palatable to have proxies control [[Class]] or is there another
> way we can help proxies over this hurdle?
DOM objects are defined in ECMAScript as "host objects". As such, they
can do whatever they want with [[Class]] (as they always have). There is
no need for proxies to change.

Anyway, I think that the idea is to define the DOM as ECMAScript
(proxies included). Following this path, maybe that WebIDL could do a
willful violation as it's sometimes done in HTML5.

Another idea is that Object.prototype.toString could return different
things for DOM objects. This can certainly be implemented in pure
ES.next with WeakMaps. It's duck-typing, so a bit ugly, but possible anyway.


More information about the es-discuss mailing list