Skip to content

Commit

Permalink
No global vars allowed. Declare 'body' in support.
Browse files Browse the repository at this point in the history
  • Loading branch information
timmywil committed Nov 18, 2011
1 parent d459bd4 commit fb94277
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
27 changes: 13 additions & 14 deletions src/support.js
Expand Up @@ -184,28 +184,27 @@ jQuery.support = (function() {
fragment.removeChild( div );

// Null elements to avoid leaks in IE
fragment = select = opt = body = marginDiv = div = input = null;
fragment = select = opt = marginDiv = div = input = null;

// Run fixed position tests at doc ready to avoid a crash
// related to the invisible body in IE8
// Run tests that need a body at doc ready
jQuery(function() {
var container, outer, inner, table, td, offsetSupport,
conMarginTop = 1,
ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",
vb = "visibility:hidden;border:0;",
style = "style='" + ptlm + "border:5px solid #000;padding:0;'",
html = "<div " + style + "><div></div></div>" +
"<table " + style + " cellpadding='0' cellspacing='0'>" +
"<tr><td></td></tr></table>";

// Reconstruct a container
body = document.getElementsByTagName("body")[0];
conMarginTop, ptlm, vb, style, html,
body = document.getElementsByTagName("body")[0];

if ( !body ) {
// Return for frameset docs that don't have a body
// These tests cannot be done
return;
}

conMarginTop = 1;
ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;";
vb = "visibility:hidden;border:0;";
style = "style='" + ptlm + "border:5px solid #000;padding:0;'";
html = "<div " + style + "><div></div></div>" +
"<table " + style + " cellpadding='0' cellspacing='0'>" +
"<tr><td></td></tr></table>";

container = document.createElement("div");
container.style.cssText = vb + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px";
body.insertBefore( container, body.firstChild );
Expand Down
2 changes: 1 addition & 1 deletion test/unit/support.js
Expand Up @@ -50,7 +50,7 @@ supportIFrameTest( "body background is not lost if set prior to loading jQuery (
for ( i in support ) {
if ( !( i in jQuery.support ) ) {
passed = false;
strictEqual( src[ i ], dest[ i ], "Unexpected property: " + i );
strictEqual( jQuery.support[ i ], support[ i ], "Unexpected property: " + i );
}
}
ok( passed, "Same support properties" );
Expand Down

0 comments on commit fb94277

Please sign in to comment.