aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/offset.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/offset.js')
-rw-r--r--test/unit/offset.js50
1 files changed, 30 insertions, 20 deletions
diff --git a/test/unit/offset.js b/test/unit/offset.js
index 0d8bcc726..f1e33bd4b 100644
--- a/test/unit/offset.js
+++ b/test/unit/offset.js
@@ -94,8 +94,10 @@ testIframe("offset/absolute", "absolute", function($, iframe) {
testIframe("offset/absolute", "absolute", function( $ ) {
expect(178);
+ var tests, offset;
+
// get offset tests
- var tests = [
+ tests = [
{ "id": "#absolute-1", "top": 1, "left": 1 },
{ "id": "#absolute-1-1", "top": 5, "left": 5 },
{ "id": "#absolute-1-1-1", "top": 9, "left": 9 },
@@ -120,7 +122,7 @@ testIframe("offset/absolute", "absolute", function( $ ) {
});
// test #5781
- var offset = $( "#positionTest" ).offset({ "top": 10, "left": 10 }).offset();
+ offset = $( "#positionTest" ).offset({ "top": 10, "left": 10 }).offset();
equal( offset.top, 10, "Setting offset on element with position absolute but 'auto' values." );
equal( offset.left, 10, "Setting offset on element with position absolute but 'auto' values." );
@@ -179,11 +181,13 @@ testIframe("offset/absolute", "absolute", function( $ ) {
testIframe("offset/relative", "relative", function( $ ) {
expect(60);
+ var ie, tests;
+
// IE is collapsing the top margin of 1px; detect and adjust accordingly
- var ie = $("#relative-1").offset().top === 6;
+ ie = $("#relative-1").offset().top === 6;
// get offset
- var tests = [
+ tests = [
{ "id": "#relative-1", "top": ie ? 6 : 7, "left": 7 },
{ "id": "#relative-1-1", "top": ie ? 13 : 15, "left": 15 },
{ "id": "#relative-2", "top": ie ? 141 : 142, "left": 27 }
@@ -238,14 +242,15 @@ testIframe("offset/relative", "relative", function( $ ) {
});
testIframe("offset/static", "static", function( $ ) {
+ expect( 80 );
- // IE is collapsing the top margin of 1px; detect and adjust accordingly
- var ie = $("#static-1").offset().top === 6;
+ var ie, tests;
- expect( 80 );
+ // IE is collapsing the top margin of 1px; detect and adjust accordingly
+ ie = $("#static-1").offset().top === 6;
// get offset
- var tests = [
+ tests = [
{ "id": "#static-1", "top": ie ? 6 : 7, "left": 7 },
{ "id": "#static-1-1", "top": ie ? 13 : 15, "left": 15 },
{ "id": "#static-1-1-1", "top": ie ? 20 : 23, "left": 23 },
@@ -306,12 +311,14 @@ testIframe("offset/static", "static", function( $ ) {
});
testIframe("offset/fixed", "fixed", function( $ ) {
- // IE is collapsing the top margin of 1px; detect and adjust accordingly
- var ie = $("#fixed-1").position().top === 2;
-
expect(34);
- var tests = [
+ var ie, tests, $noTopLeft;
+
+ // IE is collapsing the top margin of 1px; detect and adjust accordingly
+ ie = $("#fixed-1").position().top === 2;
+
+ tests = [
{
"id": "#fixed-1",
"offsetTop": 1001,
@@ -382,7 +389,7 @@ testIframe("offset/fixed", "fixed", function( $ ) {
});
// Bug 8316
- var $noTopLeft = $("#fixed-no-top-left");
+ $noTopLeft = $("#fixed-no-top-left");
if ( window.supportsFixedPosition ) {
equal( $noTopLeft.offset().top, 1007, "Check offset top for fixed element with no top set" );
equal( $noTopLeft.offset().left, 1007, "Check offset left for fixed element with no left set" );
@@ -487,15 +494,17 @@ test("chaining", function() {
test("offsetParent", function(){
expect(13);
- var body = jQuery("body").offsetParent();
+ var body, header, div, area;
+
+ body = jQuery("body").offsetParent();
equal( body.length, 1, "Only one offsetParent found." );
equal( body[0], document.documentElement, "The html element is the offsetParent of the body." );
- var header = jQuery("#qunit").offsetParent();
+ header = jQuery("#qunit").offsetParent();
equal( header.length, 1, "Only one offsetParent found." );
equal( header[0], document.documentElement, "The html element is the offsetParent of #qunit." );
- var div = jQuery("#nothiddendivchild").offsetParent();
+ div = jQuery("#nothiddendivchild").offsetParent();
equal( div.length, 1, "Only one offsetParent found." );
equal( div[0], document.getElementById("qunit-fixture"), "The #qunit-fixture is the offsetParent of #nothiddendivchild." );
@@ -510,7 +519,7 @@ test("offsetParent", function(){
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();
+ area = jQuery("#imgmap area").offsetParent();
equal( area[0], document.documentElement, "The html element is the offsetParent of the body." );
div = jQuery("<div>").css({ "position": "absolute" }).appendTo("body");
@@ -524,8 +533,9 @@ test("fractions (see #7730 and #7885)", function() {
jQuery("body").append("<div id='fractions'/>");
- var expected = { "top": 1000, "left": 1000 };
- var div = jQuery("#fractions");
+ var result,
+ expected = { "top": 1000, "left": 1000 },
+ div = jQuery("#fractions");
div.css({
"position": "absolute",
@@ -537,7 +547,7 @@ test("fractions (see #7730 and #7885)", function() {
div.offset(expected);
- var result = div.offset();
+ result = div.offset();
equal( result.top, expected.top, "Check top" );
equal( result.left, expected.left, "Check left" );