I've wanted to find a better version of 'var dwr = {};' for a while, mostly because every JS checker complains. I'm not sure why. It's worse that when used with an 'if' we might like to use a block, but { var dwr = {}; } feels like it shouldn't affect the surroundings. (though I appreciate that it does).
So doing window['dwr'] felt like a decent fix, however, and this is the strange bit, on IE:
window['dwr'] = { };
dwr.wibble = 'x';
if (dwr == null) var dwr = {};
Ends up re-defining dwr because (dwr == null) is true. I have no idea why, but IE was broken because not all declarations of DWR did it in the same way. In the end I copied what Dojo does.
Joe.
On 11/2/07, Mike Wilson <mikewse@...> wrote:
Hi
Joe,
I saw that you've
gone from
var dwr = {};
to
window['dwr'] =
{};
and then
to
this.dwr = {};
in
engine/util.js. (BTW: in what version should the old DWREngine/DWRUtil
names disappear?)
I'm
following you with the window version, but what is the rationale for the
latest version with |this| ?
Maybe it is
because of integrating with unit tests, or for multiple frame windows?
Either way it would be interesting to have a discussion about what we want
to do in these cases.
Best
regards
Mike