}
function add(l, t) {
- left += parseInt(l) || 0;
- top += parseInt(t) || 0;
+ left += parseInt(l, 10) || 0;
+ top += parseInt(t, 10) || 0;
}
return results;
// 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' );