]> source.dussan.org Git - jquery.git/commitdiff
Fix #8482, offsetParent should not return null. Closes gh-847.
authorNowres Rafid <nowres.rafed@gmail.com>
Fri, 6 Jul 2012 13:58:34 +0000 (09:58 -0400)
committerDave Methvin <dave.methvin@gmail.com>
Fri, 6 Jul 2012 14:01:32 +0000 (10:01 -0400)
src/offset.js
test/index.html
test/unit/offset.js

index fcd39ed05f802d28e46dc9a06afd7d457a82b3d1..f8fd0ec87a4d153fb24515c572d192c217c7f6f2 100644 (file)
@@ -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;
                });
        }
 });
index 9593e95a184e5e40e124312275da16d0f971b999..59dfad62de74614f820b9ee9a0d735925d95851c 100644 (file)
@@ -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>
index 972c49f7c5a3c93f75d8ea3f69781f3d251593fd..6a6cbcff5cc92b01083059737fc980c7ff97b710 100644 (file)
@@ -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() {