RE: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Domenic Denicola
-Original Message- From: es-discuss-boun...@mozilla.org [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Brendan Eich Sent: Saturday, August 11, 2012 22:57 As noted, they started out that way 17 years ago. I think WebIDL and interface-based method definition made onload, e.g.,

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Boris Zbarsky
On 8/10/12 8:17 PM, Allen Wirfs-Brock wrote: The least painful solution to the immediate FF issue may be to make indexedDB an own property of the window object rather than an inherited property. Perhaps do that for all variable-like properties (those that down need real get/set logic) of the

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Boris Zbarsky
On 8/10/12 9:00 PM, Jonas Sicking wrote: One potential solution that I think we should keep in mind is to declare that WebIDL properties *on global objects* doesn't go on the prototype chain, but rather on the global objects themselves. ... It also has the advantage that Chrome already does

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Boris Zbarsky
On 8/11/12 9:16 PM, Brendan Eich wrote: As bz and others point out, the object detection w/ var pattern can arise for operations, e.g. for requestAnimationFrame, using the same var requestAnimationFrame = window.mozRequestAnimationFrame || ... || window.requestAnimationFrame; pattern. So

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Boris Zbarsky
On 8/11/12 9:46 PM, Cameron McCormack wrote: 1. If we don't do that auto-forwarding, does Window.prototype still need to exist? What should window.__proto__ be? That's a good question. What is it in current UAs? At least some don't have a Window at all... 2. If Window.prototype still

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Boris Zbarsky
On 8/11/12 9:48 PM, Allen Wirfs-Brock wrote: I see, this makes perfect sense when onload is viewed simply as a passive property. That stops being an option once addEventListener also appears, for what it's worth. It is turning into an active side-effecting registration mechanism that

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Boris Zbarsky
On 8/11/12 10:17 PM, Allen Wirfs-Brock wrote: Requirements on the global object are specified here: http://ecma-international.org/ecma-262/5.1/#sec-15.1 It says that the value [[Prototype]] is implementation defined, but in practice in needs to inherit from Object.prototype. So,

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Boris Zbarsky
On 8/11/12 10:42 PM, Brendan Eich wrote: However, implementations (at least Gecko) give window a proto chain that is interesting: Indeed. For one thing, we haven't switched Window to the new bindings yet. This is from a stable-release Firefox Web Console. I believe it matches a real DOM

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Boris Zbarsky
On 8/11/12 10:57 PM, Brendan Eich wrote: I think WebIDL and interface-based method definition made onload, e.g., predefined on window objects, or more recently on Window.prototype. Was this useful? It's required for web compat, as I said earlier in this thread. They _could_ perhaps be

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Sigbjorn Finne
On Sun, Aug 12, 2012 at 6:30 PM, Boris Zbarsky bzbar...@mit.edu wrote: On 8/10/12 8:17 PM, Allen Wirfs-Brock wrote: ... but isn't widespread use of inherited setters to implement DOM properties fairly recent? No. Gecko has done it all along, and IE and Opera have certainly done it for

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Brendan Eich
Boris Zbarsky wrote: On 8/10/12 9:00 PM, Jonas Sicking wrote: One potential solution that I think we should keep in mind is to declare that WebIDL properties *on global objects* doesn't go on the prototype chain, but rather on the global objects themselves. ... It also has the advantage that

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Brendan Eich
Boris Zbarsky wrote: On 8/11/12 9:16 PM, Brendan Eich wrote: As bz and others point out, the object detection w/ var pattern can arise for operations, e.g. for requestAnimationFrame, using the same var requestAnimationFrame = window.mozRequestAnimationFrame || ... ||

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Boris Zbarsky
On 8/12/12 1:27 PM, Brendan Eich wrote: IOW, I think your requestAnimationFrame var+object-detection example is a good one. No difference in principle from the indexedDB case, and possibly only just luck that it has not bitten yet. True Is there a WebIDL style guide for helping decide

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Boris Zbarsky
On 8/12/12 1:31 PM, Brendan Eich wrote: There's still a problem for getter-less attributes including indexedDB, so something *still* has to change there! I'm not sure I follow this. If indexedDB is on the global as an own property, what issue remains with it? The global needs to be a flat

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Brendan Eich
Boris Zbarsky wrote: On 8/12/12 1:31 PM, Brendan Eich wrote: There's still a problem for getter-less attributes including indexedDB, so [setter-less] something *still* has to change there! I'm not sure I follow this. If indexedDB is on the global as an own property, what issue remains

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Brendan Eich
Boris Zbarsky wrote: On 8/11/12 10:42 PM, Brendan Eich wrote: However, implementations (at least Gecko) give window a proto chain that is interesting: Indeed. For one thing, we haven't switched Window to the new bindings yet. Could you lay out the new chain here, e.g.

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Brendan Eich
Boris Zbarsky wrote: On 8/11/12 10:57 PM, Brendan Eich wrote: I think WebIDL and interface-based method definition made onload, e.g., predefined on window objects, or more recently on Window.prototype. Was this useful? It's required for web compat, as I said earlier in this thread. They

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Brandon Benvie
One incompatibility in current implementations is that Object.getPrototypeOf(window) in Opera is Object.prototype whereas the rest have something like Window.prototype (Window doesn't exist in Opera). An interesting consequence of mutable __proto__ and having the global variable record be a

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Brandon Benvie
An even more interesting scenario is something like `global.__proto__ = Proxy.create()` ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Brendan Eich
Brandon Benvie wrote: An even more interesting scenario is something like `global.__proto__ = Proxy.create()` Yes, I mentioned proxies on the global's proto-chain (and mutable __proto__) up-thread, here: https://mail.mozilla.org/pipermail/es-discuss/2012-August/024483.html Quote: We

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Boris Zbarsky
On 8/12/12 1:59 PM, Brendan Eich wrote: Boris Zbarsky wrote: On 8/11/12 10:42 PM, Brendan Eich wrote: However, implementations (at least Gecko) give window a proto chain that is interesting: Indeed. For one thing, we haven't switched Window to the new bindings yet. Could you lay out the

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Boris Zbarsky
On 8/12/12 3:02 PM, Brandon Benvie wrote: An even more interesting scenario is something like `global.__proto__ = Proxy.create()` That's basically what the Global Scope Polluter does. That's certainly how I plan to implement it in Gecko in the WebIDL bindings: Window.prototype.__proto__

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Brendan Eich
Boris Zbarsky wrote: On 8/12/12 3:02 PM, Brandon Benvie wrote: An even more interesting scenario is something like `global.__proto__ = Proxy.create()` That's basically what the Global Scope Polluter does. That's certainly how I plan to implement it in Gecko in the WebIDL bindings:

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Boris Zbarsky
On 8/12/12 4:31 PM, Brendan Eich wrote: However, check me here: the GSP makes own global properties on demand, when names of DOM elements that come from name= and id= attributes (or just id=? I forget) are used as identifier expressions. That's what it does in Gecko's impl right now. It has a

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Sigbjorn Finne
On Sun, Aug 12, 2012 at 8:57 PM, Brandon Benvie bran...@brandonbenvie.comwrote: One incompatibility in current implementations is that Object.getPrototypeOf(window) in Opera is Object.prototype whereas the rest have something like Window.prototype (Window doesn't exist in Opera). You may

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Boris Zbarsky
On 8/12/12 4:55 PM, Boris Zbarsky wrote: There was a bunch of previous discussion about this at http://lists.w3.org/Archives/Public/public-script-coord/2012JanMar/0010.html and following, though it's not clear to me now whether the solution we decided on allows var to shadow these named props as

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Brendan Eich
Boris Zbarsky wrote: On 8/12/12 4:31 PM, Brendan Eich wrote: However, check me here: the GSP makes own global properties on demand, when names of DOM elements that come from name= and id= attributes (or just id=? I forget) are used as identifier expressions. That's what it does in Gecko's

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Brendan Eich
Boris Zbarsky wrote: Note that data in http://lists.w3.org/Archives/Public/public-script-coord/2012JanMar/0033.html suggests that IE also implements the erratum to 5.1 we were talking about up-thread. Oh what a tangled web we weave. Yes, current thinking is that we should take the erratum

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Boris Zbarsky
On 8/12/12 5:23 PM, Brendan Eich wrote: Boris Zbarsky wrote: On 8/12/12 4:31 PM, Brendan Eich wrote: However, check me here: the GSP makes own global properties on demand, when names of DOM elements that come from name= and id= attributes (or just id=? I forget) are used as identifier

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Boris Zbarsky
On 8/12/12 5:29 PM, Brendan Eich wrote: Boris Zbarsky wrote: Note that data in http://lists.w3.org/Archives/Public/public-script-coord/2012JanMar/0033.html suggests that IE also implements the erratum to 5.1 we were talking about up-thread. Oh what a tangled web we weave. Yes, current

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Brendan Eich
Boris Zbarsky wrote: But name collisions if the HTML uses a common id= value and the JS wants that for a global var seem scarily likely. Yes, using the GSP is more or less a recipe for fail. That's why I'd hoped to restrict it to quirks mode pages. Ah, well. I was with you on that. I

Re: var declarations shadowing properties from Window.prototype

2012-08-12 Thread Cameron McCormack
Boris Zbarsky: Per the current spec proposal, the GSP lives on the proto chain and exposes the various id/name stuff as own properties on itself, with the usual caveats about checking up the proto chain first that DOM named access has. See