offset: make sure there is a parent node to work on while calculating scroll offsets (#2073)

This commit is contained in:
Brandon Aaron 2007-12-19 19:07:12 +00:00
parent add0681f90
commit e2fc993334

View file

@ -55,7 +55,7 @@ jQuery.fn.offset = function() {
}
// Get parent scroll offsets
while ( parent.tagName && !/^body|html$/i.test(parent.tagName) ) {
while ( parent && parent.tagName && !/^body|html$/i.test(parent.tagName) ) {
// 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