jQuery 1.4.2 fix for IE9

As far as I can see jQuery 1.4.2 fails to load in IE9. At least, that is the case for the jQuery js file, coming from Google CDN. Solution.

Ok diving gear on, and yet another brave plunge into the depth of jQuery.
And here is our specimen. Somewhere around line 900, in the jQuery.1.4.2.js :
[sourcecode lang=”javascript”]
// Make sure that the execution of code works by injecting a script
// tag with appendChild/createTextNode
// (IE doesn’t support this, fails, and uses .text instead)
if (window[id]) {
jQuery.support.scriptEval = true;
delete window[id];
}
[/sourcecode]
Instead of above, the bellow should be :
[sourcecode lang=”javascript”]
// Make sure that the execution of code works by injecting a script
// tag with appendChild/createTextNode
// (IE doesn’t support this, fails, and uses .text instead)
if (window[id]) {
jQuery.support.scriptEval = true;
try { // DBJ fix for IE9
delete window[id];
} catch (x) { }
}
[/sourcecode]
This would do. And should stay. Even after discussion erupts, and fades away, on the issue of should “Chakra” throw the serious fuss on

, or it should perhaps not.

Update 2011-05-13

In IE9 as released (not beta, the real stuff)

delete window.null

returns: true . That is an improvement and that is my little contribution to IE9. Gaurav Seth always reads my emails, thanks Seth.

–DBJ