RE: "var" declarations shadowing properties from Window.prototype

> From: Brendan Eich [mailto:brendan@mozilla.com]
> 
> Travis Leithead wrote:
> > I still have my doubts about the magnitude of this problem,
> 
> Which problem? Clearly not all stable browsers have rolled out the ES5.1
> erratum fix whereby var ignores the prototype chain. Also clearly, WebKit-
> based browsers bind attribiutes as "own" properties. We won't know unless
> and and until all browsers take the heat we're taking.
> 
> Not sure you're taking this heat yet either!

No, we seemed to have lucked out in that regard.


> Furthermore, independent of this issue, I raised the (in hindsight
> untenable) injection of readonly attributes onto the global object or its
> prototype chain. This is just bad for backward compatibility on principle, and
> based on 16 years of experience. It's why we have [Replaceable]. So I think
> we should do something along the suggested lines (making that the default).
> 
> > but if I'm wrong then I'd at least like to be able to grandfather-in some
> legacy APIs like addEventListener (or other APIs that make sense to have a
> single shared entry point for easy monkey patching).
> 
> Is this a used use-case? There's no grandfathering if WebKit-based browsers
> and Opera have never done it.

It's an ideal we strive for, but as you say, not widely implemented...

> Are you guys using EventTarget.prototype.addEventListener = ... to affect
> window's event listening?

...just like the proposal to have everything inherit from EventTarget. IE currently mixes the API into all the relevant objects, so we're not practicing what we preach here.

Received on Thursday, 16 August 2012 22:21:14 UTC