X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Foffset.js;fp=test%2Funit%2Foffset.js;h=f9747decbc2ac2c68dec4ce00332ed7808efff4f;hb=a3b8ac413f9c55994922c20b39223ab9ae6d1afa;hp=b6c50ff71d334fdaa9c68a8a60a15d737f7ec4e4;hpb=f0681d98fe1fcb2995eca50a41c1c66407eab97a;p=jquery.git diff --git a/test/unit/offset.js b/test/unit/offset.js index b6c50ff..f9747de 100644 --- a/test/unit/offset.js +++ b/test/unit/offset.js @@ -145,7 +145,32 @@ testoffset("body", function( jQuery ) { equals( jQuery('body').offset().left, 1, "jQuery('#body').offset().left" ); }); +test("offsetParent", function(){ + expect(11); + var body = jQuery("body").offsetParent(); + equals( body.length, 1, "Only one offsetParent found." ); + equals( body[0], document.body, "The body is its own offsetParent." ); + + var header = jQuery("#header").offsetParent(); + equals( header.length, 1, "Only one offsetParent found." ); + equals( header[0], document.body, "The body is the offsetParent." ); + + var div = jQuery("#nothiddendivchild").offsetParent(); + equals( div.length, 1, "Only one offsetParent found." ); + equals( div[0], document.body, "The body is the offsetParent." ); + + jQuery("#nothiddendiv").css("position", "relative"); + + div = jQuery("#nothiddendivchild").offsetParent(); + equals( div.length, 1, "Only one offsetParent found." ); + equals( div[0], jQuery("#nothiddendiv")[0], "The div is the offsetParent." ); + + div = jQuery("body, #nothiddendivchild").offsetParent(); + equals( div.length, 2, "Two offsetParent found." ); + equals( div[0], document.body, "The body is the offsetParent." ); + equals( div[1], jQuery("#nothiddendiv")[0], "The div is the offsetParent." ); +}); function testoffset(name, fn) { @@ -177,4 +202,4 @@ function testoffset(name, fn) { iframe.contentWindow.location = src; return iframe; } -} \ No newline at end of file +}