« Return to Thread: with and scope chain augmentation

Re: with and scope chain augmentation

by Brendan Eich-3 :: Rate this Message:

Reply to Author | View in Thread

On Jun 24, 2009, at 11:38 AM, Mike Wilson wrote:

> Jason Orendorff wrote:
>> Eeuuurgh.  In that case, what David-Sarah said.
>
> What did he say?

He said "don't do that", to paraphrase. Full quote:

"The 'with' can be in non-strict code, which is perfectly
adequate for implementing a backward-compatible misfeature
(the peculiar scope chain of a DOM0 event handler)."

The nested DOM object scopes for event handlers was something I did to  
allow brevity in inline event handler code. On balance it was a  
mistake, but it was so popular that the VXML spec actually goes nuts  
and reifies nested XML tags as objects on the scope chain for its ES  
scripting model!

This makes for a confusing tower of scopes. You can't always see the  
bindings, since an XML or HTML doc can be large. With the DOM, pieces  
of the namespace can be bound implicitly or in obscure ways. And  
"unobtrusive JavaScript" favors no event handler code bodies at all.

So yeah: "don't do that" (don't use strict mode for any with hacks  
that emulate bad old web APIs such as event handler scope).

Or to shorten it further a la jorendorff: Eeuuurgh.

/be
_______________________________________________
es-discuss mailing list
es-discuss@...
https://mail.mozilla.org/listinfo/es-discuss

 « Return to Thread: with and scope chain augmentation