diff options
author | Nowres Rafid <nowres.rafed@gmail.com> | 2012-07-06 09:58:34 -0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2012-07-06 10:01:32 -0400 |
commit | aaf134bb7092efe7b450fc08ca5cc3c53cb00d76 (patch) | |
tree | 633a1527c42fd99a1d0bcd6ca683440371c0d940 | |
parent | 05aff402310d7db5d15f96b15071af6aa21a2afc (diff) | |
download | jquery-aaf134bb7092efe7b450fc08ca5cc3c53cb00d76.tar.gz jquery-aaf134bb7092efe7b450fc08ca5cc3c53cb00d76.zip |
Fix #8482, offsetParent should not return null. Closes gh-847.
-rw-r--r-- | src/offset.js | 2 | ||||
-rw-r--r-- | test/index.html | 3 | ||||
-rw-r--r-- | test/unit/offset.js | 5 |
3 files changed, 8 insertions, 2 deletions
diff --git a/src/offset.js b/src/offset.js index fcd39ed05..f8fd0ec87 100644 --- a/src/offset.js +++ b/src/offset.js @@ -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; }); } }); diff --git a/test/index.html b/test/index.html index 9593e95a1..59dfad62d 100644 --- a/test/index.html +++ b/test/index.html @@ -305,6 +305,9 @@ Z</textarea> <div id="fx-tests"></div> </div> + <map name="imgmap" id="imgmap"> + <area shape="rect" coords="0,0,200,50"> + </map> </body> </html> diff --git a/test/unit/offset.js b/test/unit/offset.js index 972c49f7c..6a6cbcff5 100644 --- a/test/unit/offset.js +++ b/test/unit/offset.js @@ -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." ); @@ -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() { |