From b398a68333d5eb9859fabb1ceabe84a1a753760a Mon Sep 17 00:00:00 2001 From: Daniel Gálvez Date: Sun, 19 Aug 2012 21:53:09 +0200 Subject: Fix #11542. document.body should not be special in .offset() and document.documentElement is the default element.offsetParent. Close gh-899. --- test/unit/offset.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'test/unit') diff --git a/test/unit/offset.js b/test/unit/offset.js index ef98f8417..8bca2d8c1 100644 --- a/test/unit/offset.js +++ b/test/unit/offset.js @@ -452,10 +452,12 @@ testIframe("offset/scroll", "scroll", function( $, win ) { }); testIframe("offset/body", "body", function( $ ) { - expect(2); + expect(4); equal( $("body").offset().top, 1, "jQuery('#body').offset().top" ); equal( $("body").offset().left, 1, "jQuery('#body').offset().left" ); + equal( $("#firstElement").position().left, 5, "$('#firstElement').position().left" ); + equal( $("#firstElement").position().top, 5, "$('#firstElement').position().top" ); }); test("chaining", function() { @@ -471,15 +473,15 @@ test("offsetParent", function(){ var body = jQuery("body").offsetParent(); equal( body.length, 1, "Only one offsetParent found." ); - equal( body[0], document.body, "The body is its own offsetParent." ); + equal( body[0], document.documentElement, "The html element is the offsetParent of the body." ); var header = jQuery("#qunit-header").offsetParent(); equal( header.length, 1, "Only one offsetParent found." ); - equal( header[0], document.body, "The body is the offsetParent." ); + equal( header[0], document.documentElement, "The html element is the offsetParent of the body." ); var div = jQuery("#nothiddendivchild").offsetParent(); equal( div.length, 1, "Only one offsetParent found." ); - equal( div[0], document.body, "The body is the offsetParent." ); + equal( div[0], document.documentElement, "The html element is the offsetParent of the body." ); jQuery("#nothiddendiv").css("position", "relative"); @@ -489,11 +491,11 @@ test("offsetParent", function(){ div = jQuery("body, #nothiddendivchild").offsetParent(); equal( div.length, 2, "Two offsetParent found." ); - equal( div[0], document.body, "The body is the offsetParent." ); + equal( div[0], document.documentElement, "The html element is the offsetParent of the body." ); 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." ); + equal( area[0], document.documentElement, "The html element is the offsetParent of the body." ); }); test("fractions (see #7730 and #7885)", function() { -- cgit v1.2.3