diff options
author | timmywil <timmywillisn@gmail.com> | 2011-11-18 09:28:54 -0500 |
---|---|---|
committer | timmywil <timmywillisn@gmail.com> | 2011-11-18 09:29:10 -0500 |
commit | fb94277b6ee460c88df470f7bc9b64b4b3af2c9e (patch) | |
tree | 2128337f68fa66b760d1e146ce797dff977a300c /src/support.js | |
parent | d459bd40d03892b32c3b58a6c3f0bd4f44a08763 (diff) | |
download | jquery-fb94277b6ee460c88df470f7bc9b64b4b3af2c9e.tar.gz jquery-fb94277b6ee460c88df470f7bc9b64b4b3af2c9e.zip |
No global vars allowed. Declare 'body' in support.
Diffstat (limited to 'src/support.js')
-rw-r--r-- | src/support.js | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/support.js b/src/support.js index 2d9107ac9..da5fec8ff 100644 --- a/src/support.js +++ b/src/support.js @@ -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 ); |