aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrandon Aaron <brandon.aaron@gmail.com>2007-12-12 16:55:55 +0000
committerBrandon Aaron <brandon.aaron@gmail.com>2007-12-12 16:55:55 +0000
commit58c640fb1ce09a03399a3a441716cca23f3f2d04 (patch)
treeab1b71217c668af4f94654b5ae2c6e732c8fa5dd /src
parent279f77e9609fba62c11a06f8c65221b16f7bc7d4 (diff)
downloadjquery-58c640fb1ce09a03399a3a441716cca23f3f2d04.tar.gz
jquery-58c640fb1ce09a03399a3a441716cca23f3f2d04.zip
Added more unit tests for offset. Fixed an offset issue relating to table header cells in Opera
Diffstat (limited to 'src')
-rw-r--r--src/offset.js20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/offset.js b/src/offset.js
index e74556cd2..257035816 100644
--- a/src/offset.js
+++ b/src/offset.js
@@ -5,7 +5,7 @@ jQuery.fn.offset = function() {
var left = 0, top = 0, elem = this[0], results;
if ( elem ) with ( jQuery.browser ) {
- var parent = elem.parentNode,
+ var parent = elem.parentNode,
offsetChild = elem,
offsetParent = elem.offsetParent,
doc = elem.ownerDocument,
@@ -17,10 +17,8 @@ jQuery.fn.offset = function() {
var box = elem.getBoundingClientRect();
// Add the document scroll offsets
- add(
- box.left + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
- box.top + Math.max(doc.documentElement.scrollTop, doc.body.scrollTop)
- );
+ add(box.left + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
+ box.top + Math.max(doc.documentElement.scrollTop, doc.body.scrollTop));
// IE adds the HTML element's border, by default it is medium which is 2px
// IE 6 and 7 quirks mode the border width is overwritable by the following css html { border: 0; }
@@ -35,7 +33,7 @@ jQuery.fn.offset = function() {
// Initial element offsets
add( elem.offsetLeft, elem.offsetTop );
-
+
// Get parent offsets
while ( offsetParent ) {
// Add offsetParent offsets
@@ -58,8 +56,8 @@ jQuery.fn.offset = function() {
// Get parent scroll offsets
while ( parent.tagName && !/^body|html$/i.test(parent.tagName) ) {
- // Remove parent scroll UNLESS that parent is inline or a table-row to work around Opera inline/table scrollLeft/Top bug
- if ( !/^inline|table-row.*$/i.test(jQuery.css(parent, "display")) )
+ // Remove parent scroll UNLESS that parent is inline or a table to work around Opera inline/table scrollLeft/Top bug
+ if ( !/^inline|table.*$/i.test(jQuery.css(parent, "display")) )
// Subtract parent scroll offsets
add( -parent.scrollLeft, -parent.scrollTop );
@@ -79,10 +77,8 @@ jQuery.fn.offset = function() {
// Add the document scroll offsets if position is fixed
if ( fixed )
- add(
- Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
- Math.max(doc.documentElement.scrollTop, doc.body.scrollTop)
- );
+ add(Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
+ Math.max(doc.documentElement.scrollTop, doc.body.scrollTop));
}
// Return an object with top and left properties