aboutsummaryrefslogtreecommitdiffstats
path: root/src/support.js
diff options
context:
space:
mode:
authorRick Waldron <waldron.rick@gmail.com>2011-09-19 21:03:41 -0400
committertimmywil <timmywillisn@gmail.com>2011-09-19 21:03:41 -0400
commitf60213648cefa9b53289ad01a55ead22a15e6ee1 (patch)
tree74f93acaba183bd24a9a8beab1efd7e39e862258 /src/support.js
parent9ecdb2472be7661477564e46bce51432d4a5a84e (diff)
downloadjquery-f60213648cefa9b53289ad01a55ead22a15e6ee1.tar.gz
jquery-f60213648cefa9b53289ad01a55ead22a15e6ee1.zip
Landing pull request 477. 1.7 jQuery.offset.supportsFixedPosition. Fixes #6809.
More Details: - https://github.com/jquery/jquery/pull/477 - http://bugs.jquery.com/ticket/6809
Diffstat (limited to 'src/support.js')
-rw-r--r--src/support.js46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/support.js b/src/support.js
index ad1bd9a57..fb730dca7 100644
--- a/src/support.js
+++ b/src/support.js
@@ -20,7 +20,8 @@ jQuery.support = (function() {
events,
eventName,
i,
- isSupported;
+ isSupported,
+ offsetSupport;
// Preliminary tests
div.setAttribute("className", "t");
@@ -249,6 +250,49 @@ jQuery.support = (function() {
}
}
+ // Determine fixed-position support early
+ offsetSupport = (function( body, container ) {
+
+ var outer, inner, table, td, supports,
+ bodyMarginTop = parseFloat( body.style.marginTop ) || 0,
+ ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;",
+ style = "style='" + ptlm + "margin:0;border:5px solid #000;padding:0;'",
+ html = "<div " + style + "><div></div></div>" +
+ "<table " + style + " cellpadding='0' cellspacing='0'>" +
+ "<tr><td></td></tr></table>";
+
+ container.style.cssText = ptlm + "border:0;visibility:hidden";
+
+ container.innerHTML = html;
+ body.insertBefore( container, body.firstChild );
+ outer = container.firstChild;
+ inner = outer.firstChild;
+ td = outer.nextSibling.firstChild.firstChild;
+
+ supports = {
+ doesNotAddBorder: (inner.offsetTop !== 5),
+ doesAddBorderForTableAndCells: (td.offsetTop === 5)
+ }
+
+ inner.style.position = "fixed";
+ inner.style.top = "20px";
+
+ // safari subtracts parent border width here which is 5px
+ supports.supportsFixedPosition = (inner.offsetTop === 20 || inner.offsetTop === 15);
+ inner.style.position = inner.style.top = "";
+
+ outer.style.overflow = "hidden";
+ outer.style.position = "relative";
+
+ supports.subtractsBorderForOverflowNotVisible = (inner.offsetTop === -5);
+ supports.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
+
+ return supports;
+
+ })( testElement, div );
+
+ jQuery.extend( support, offsetSupport );
+
// Null connected elements to avoid leaks in IE
testElement = fragment = select = opt = body = marginDiv = div = input = null;