[Harmony Proxies] Proposal: Property fixing

Rick Waldron waldron.rick at gmail.com
Thu May 12 17:55:46 PDT 2011


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. "

Thanks in advance!

Rick



-- Sent from my Palm Pre
On May 12, 2011 8:12 PM, David Bruant <david.bruant at labri.fr> wrote: 

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.

David
_______________________________________________
es-discuss mailing list
es-discuss at mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110512/5b1596ee/attachment.html>


More information about the es-discuss mailing list