Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix #8482, offsetParent should not return null. Closes gh-847.
  • Loading branch information
Nowres Rafid authored and dmethvin committed Jul 6, 2012
1 parent 05aff40 commit aaf134b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/offset.js
Expand Up @@ -138,7 +138,7 @@ jQuery.fn.extend({
while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
offsetParent = offsetParent.offsetParent;
}
return offsetParent;
return offsetParent || document.body;
});
}
});
Expand Down
3 changes: 3 additions & 0 deletions test/index.html
Expand Up @@ -305,6 +305,9 @@ <h2 id="qunit-userAgent"></h2>

<div id="fx-tests"></div>
</div>
<map name="imgmap" id="imgmap">
<area shape="rect" coords="0,0,200,50">
</map>

</body>
</html>
5 changes: 4 additions & 1 deletion test/unit/offset.js
Expand Up @@ -440,7 +440,7 @@ test("chaining", function() {
});

test("offsetParent", function(){
expect(11);
expect(12);

var body = jQuery("body").offsetParent();
equal( body.length, 1, "Only one offsetParent found." );
Expand All @@ -464,6 +464,9 @@ test("offsetParent", function(){
equal( div.length, 2, "Two offsetParent found." );
equal( div[0], document.body, "The body is the offsetParent." );
equal( div[1], jQuery("#nothiddendiv")[0], "The div is the offsetParent." );

var area = jQuery("#imgmap area").offsetParent();
equal( area[0], document.body, "The body is the offsetParent." );
});

test("fractions (see #7730 and #7885)", function() {
Expand Down

0 comments on commit aaf134b

Please sign in to comment.