diff options
author | Mike Sherov <mike.sherov@gmail.com> | 2012-04-05 21:51:27 -0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2012-04-05 21:55:28 -0400 |
commit | 77536f5cb2ab042ac8be40ba59f36d8f3bd7e4d1 (patch) | |
tree | 1085e8ca438ac0dde625080c9b202eee8b6822a6 /src/support.js | |
parent | 91a6d9dafc402e78b76d1ea41d70480b42dfde60 (diff) | |
download | jquery-77536f5cb2ab042ac8be40ba59f36d8f3bd7e4d1.tar.gz jquery-77536f5cb2ab042ac8be40ba59f36d8f3bd7e4d1.zip |
Fix #10996, simplify offset code by forsaking ancient browsers.
Diffstat (limited to 'src/support.js')
-rw-r--r-- | src/support.js | 41 |
1 files changed, 5 insertions, 36 deletions
diff --git a/src/support.js b/src/support.js index baebaa2a0..5a0d1b731 100644 --- a/src/support.js +++ b/src/support.js @@ -178,9 +178,8 @@ jQuery.support = (function() { // Run tests that need a body at doc ready jQuery(function() { - var container, outer, inner, table, td, offsetSupport, - marginDiv, conMarginTop, style, html, positionTopLeftWidthHeight, - paddingMarginBorderVisibility, paddingMarginBorder, + var container, offsetSupport, marginDiv, + conMarginTop = 1, body = document.getElementsByTagName("body")[0]; if ( !body ) { @@ -188,17 +187,8 @@ jQuery.support = (function() { return; } - conMarginTop = 1; - paddingMarginBorder = "padding:0;margin:0;border:"; - positionTopLeftWidthHeight = "position:absolute;top:0;left:0;width:1px;height:1px;"; - paddingMarginBorderVisibility = paddingMarginBorder + "0;visibility:hidden;"; - style = "style='" + positionTopLeftWidthHeight + paddingMarginBorder + "5px solid #000;"; - html = "<div " + style + "display:block;'><div style='" + paddingMarginBorder + "0;display:block;overflow:hidden;'></div></div>" + - "<table " + style + "' cellpadding='0' cellspacing='0'>" + - "<tr><td></td></tr></table>"; - container = document.createElement("div"); - container.style.cssText = paddingMarginBorderVisibility + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px"; + container.style.cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px"; body.insertBefore( container, body.firstChild ); // Construct the test element @@ -212,7 +202,7 @@ jQuery.support = (function() { // display:none (it is still safe to use offsets if a parent element is // hidden; don safety goggles and see bug #4512 for more information). // (only IE 8 fails this test) - div.innerHTML = "<table><tr><td style='" + paddingMarginBorder + "0;display:none'></td><td>t</td></tr></table>"; + div.innerHTML = "<table><tr><td style='padding:0;margin:0;border:0;display:none'></td><td>t</td></tr></table>"; tds = div.getElementsByTagName( "td" ); isSupported = ( tds[ 0 ].offsetHeight === 0 ); @@ -260,31 +250,10 @@ jQuery.support = (function() { support.shrinkWrapBlocks = ( div.offsetWidth !== 3 ); } - div.style.cssText = positionTopLeftWidthHeight + paddingMarginBorderVisibility; - div.innerHTML = html; - - outer = div.firstChild; - inner = outer.firstChild; - td = outer.nextSibling.firstChild.firstChild; - offsetSupport = { - doesNotAddBorder: ( inner.offsetTop !== 5 ), - doesAddBorderForTableAndCells: ( td.offsetTop === 5 ) + doesNotIncludeMarginInBodyOffset: ( body.offsetTop !== conMarginTop ) }; - inner.style.position = "fixed"; - inner.style.top = "20px"; - - // safari subtracts parent border width here which is 5px - offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 ); - inner.style.position = inner.style.top = ""; - - outer.style.overflow = "hidden"; - outer.style.position = "relative"; - - offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 ); - offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop ); - if ( window.getComputedStyle ) { div.style.marginTop = "1%"; support.pixelMargin = ( window.getComputedStyle( div, null ) || { marginTop: 0 } ).marginTop !== "1%"; |