On Jun 23, 2009, at 5:18 PM, Jason Orendorff wrote:
On Mon, Jun 22, 2009 at 2:43 PM, Mike Wilson<[email protected]>
wrote:
I sympathize with the slide "Problem: Can't emulate
platform objects" (which is addressed by e g getter/setter
properties), but the removal of with(){} in ES5 strict mode
would mean it gets harder to emulate the scope chain
augmentation done by browsers?
Actually, I think we do this by wrapping event handlers in something
like
(function (event) { ... })
so "with" is not involved. In fact, surely everyone does something
like this, as event handlers have to support stuff like "return
false;".
Last time I checked, most of the browsers actually *still were
augmenting scope* of event handlers as if by using "with". There's
been some research on this subject first by Cornford, then by Garrett
Smith. Most of it is documented at <http://jibbering.com/faq/names/event_handler.html
>
In a nutshell, if one wanted to create a function object out of a
string value of intrinsic event attribute, something along these lines
would need to be used (for a more or less complete emulation):
function eventHandlerFromAttr(element, attrValue){
return function(e){
with(document){
with(element){
var fn = eval('(function(event){' + attrValue + '})');
return fn.call(element, e);
}
}
}
}
[...]
--
Juriy Zaytsev
Co-founder, BitSonnet, Corp.
Core developer, Prototype.js
[email protected]_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss