Reverted back to using the num helper method in offset.js
[jquery.git] / src / offset.js
index a35fed5..ef999d8 100644 (file)
@@ -91,8 +91,8 @@ jQuery.fn.offset = function() {
        }
 
        function add(l, t) {
-               left += parseInt(l) || 0;
-               top += parseInt(t) || 0;
+               left += parseInt(l, 10) || 0;
+               top += parseInt(t, 10) || 0;
        }
 
        return results;
@@ -107,11 +107,13 @@ jQuery.fn.extend({
                        // Get *real* offsetParent
                        var offsetParent = this.offsetParent(),
 
-                               // Get correct offsets
-                               offset       = this.offset(),                           
-                               parentOffset = offsetParent.offset();
+                       // Get correct offsets
+                       offset       = this.offset(),
+                       parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? { top: 0, left: 0 } : offsetParent.offset();
 
                        // Subtract element margins
+                       // note: when an element has margin: auto the offsetLeft and marginLeft 
+                       // are the same in Safari causing offset.left to incorrectly be 0
                        offset.top  -= num( this, 'marginTop' );
                        offset.left -= num( this, 'marginLeft' );