mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Make unit tests friendly to Closure Compiler. Closes gh-845.
Conflicts: test/unit/effects.js test/unit/offset.js
This commit is contained in:
parent
3dc77c4bfa
commit
de9bed319e
@ -9,7 +9,8 @@
|
||||
"trailing": true,
|
||||
"undef": true,
|
||||
"smarttabs": true,
|
||||
"maxerr": 100
|
||||
"maxerr": 100,
|
||||
"sub": true
|
||||
},
|
||||
"globals": {
|
||||
"define": true,
|
||||
|
@ -337,7 +337,7 @@ test(".ajax() - retry with jQuery.ajax( this )", function() {
|
||||
ok( true , "Test retrying with jQuery.ajax(this) works" );
|
||||
jQuery.ajax({
|
||||
url: url("data/errorWithText.php"),
|
||||
data: { x: 1 },
|
||||
data: { "x": 1 },
|
||||
beforeSend: function() {
|
||||
if ( !previousUrl ) {
|
||||
previousUrl = this.url;
|
||||
@ -367,9 +367,9 @@ test(".ajax() - headers" , function() {
|
||||
});
|
||||
|
||||
var requestHeaders = {
|
||||
siMPle: "value",
|
||||
"siMPle": "value",
|
||||
"SometHing-elsE": "other value",
|
||||
OthEr: "something else"
|
||||
"OthEr": "something else"
|
||||
},
|
||||
list = [],
|
||||
i;
|
||||
@ -827,7 +827,7 @@ test("jQuery.ajax - HEAD requests", function() {
|
||||
|
||||
jQuery.ajax({
|
||||
url: url("data/name.html"),
|
||||
data: { whip_it: "good" },
|
||||
data: { "whip_it": "good" },
|
||||
type: "HEAD",
|
||||
success: function(data, status, xhr){
|
||||
var h = xhr.getAllResponseHeaders();
|
||||
@ -904,16 +904,16 @@ test("jQuery.ajax - beforeSend, cancel request manually", function() {
|
||||
});
|
||||
});
|
||||
|
||||
window.foobar = null;
|
||||
window.testFoo = undefined;
|
||||
window["foobar"] = null;
|
||||
window["testFoo"] = undefined;
|
||||
|
||||
test("jQuery.ajax - dataType html", function() {
|
||||
expect(5);
|
||||
stop();
|
||||
|
||||
var verifyEvaluation = function() {
|
||||
equal( testFoo, "foo", "Check if script was evaluated for datatype html" );
|
||||
equal( foobar, "bar", "Check if script src was evaluated for datatype html" );
|
||||
equal( window["testFoo"], "foo", "Check if script was evaluated for datatype html" );
|
||||
equal( window["foobar"], "bar", "Check if script src was evaluated for datatype html" );
|
||||
|
||||
start();
|
||||
};
|
||||
@ -971,47 +971,47 @@ test("jQuery.param()", function() {
|
||||
|
||||
equal( !jQuery.ajaxSettings.traditional, true, "traditional flag, falsy by default" );
|
||||
|
||||
var params = {foo:"bar", baz:42, quux:"All your base are belong to us"};
|
||||
var params = {"foo":"bar", "baz":42, "quux":"All your base are belong to us"};
|
||||
equal( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" );
|
||||
|
||||
params = {"string":"foo","null":null,"undefined":undefined};
|
||||
equal( jQuery.param(params), "string=foo&null=&undefined=", "handle nulls and undefineds properly" );
|
||||
|
||||
params = {someName: [1, 2, 3], regularThing: "blah" };
|
||||
params = {"someName": [1, 2, 3], "regularThing": "blah" };
|
||||
equal( jQuery.param(params), "someName%5B%5D=1&someName%5B%5D=2&someName%5B%5D=3®ularThing=blah", "with array" );
|
||||
|
||||
params = {foo: ["a", "b", "c"]};
|
||||
params = {"foo": ["a", "b", "c"]};
|
||||
equal( jQuery.param(params), "foo%5B%5D=a&foo%5B%5D=b&foo%5B%5D=c", "with array of strings" );
|
||||
|
||||
params = {foo: ["baz", 42, "All your base are belong to us"] };
|
||||
params = {"foo": ["baz", 42, "All your base are belong to us"] };
|
||||
equal( jQuery.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" );
|
||||
|
||||
params = {foo: { bar: "baz", beep: 42, quux: "All your base are belong to us" } };
|
||||
params = {"foo": { "bar": "baz", "beep": 42, "quux": "All your base are belong to us" } };
|
||||
equal( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" );
|
||||
|
||||
params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
|
||||
equal( decodeURIComponent( jQuery.param(params) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=&i[]=10&i[]=11&j=true&k=false&l[]=&l[]=0&m=cowboy+hat?", "huge structure" );
|
||||
|
||||
params = { a: [ 0, [ 1, 2 ], [ 3, [ 4, 5 ], [ 6 ] ], { b: [ 7, [ 8, 9 ], [ { c: 10, d: 11 } ], [ [ 12 ] ], [ [ [ 13 ] ] ], { e: { f: { g: [ 14, [ 15 ] ] } } }, 16 ] }, 17 ] };
|
||||
params = { "a": [ 0, [ 1, 2 ], [ 3, [ 4, 5 ], [ 6 ] ], { "b": [ 7, [ 8, 9 ], [ { "c": 10, "d": 11 } ], [ [ 12 ] ], [ [ [ 13 ] ] ], { "e": { "f": { "g": [ 14, [ 15 ] ] } } }, 16 ] }, 17 ] };
|
||||
equal( decodeURIComponent( jQuery.param(params) ), "a[]=0&a[1][]=1&a[1][]=2&a[2][]=3&a[2][1][]=4&a[2][1][]=5&a[2][2][]=6&a[3][b][]=7&a[3][b][1][]=8&a[3][b][1][]=9&a[3][b][2][0][c]=10&a[3][b][2][0][d]=11&a[3][b][3][0][]=12&a[3][b][4][0][0][]=13&a[3][b][5][e][f][g][]=14&a[3][b][5][e][f][g][1][]=15&a[3][b][]=16&a[]=17", "nested arrays" );
|
||||
|
||||
params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
|
||||
params = { "a":[1,2], "b":{ "c":3, "d":[4,5], "e":{ "x":[6], "y":7, "z":[8,9] }, "f":true, "g":false, "h":undefined }, "i":[10,11], "j":true, "k":false, "l":[undefined,0], "m":"cowboy hat?" };
|
||||
equal( jQuery.param(params,true), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=&l=0&m=cowboy+hat%3F", "huge structure, forced traditional" );
|
||||
|
||||
equal( decodeURIComponent( jQuery.param({ a: [1,2,3], "b[]": [4,5,6], "c[d]": [7,8,9], e: { f: [10], g: [11,12], h: 13 } }) ), "a[]=1&a[]=2&a[]=3&b[]=4&b[]=5&b[]=6&c[d][]=7&c[d][]=8&c[d][]=9&e[f][]=10&e[g][]=11&e[g][]=12&e[h]=13", "Make sure params are not double-encoded." );
|
||||
equal( decodeURIComponent( jQuery.param({ "a": [1,2,3], "b[]": [4,5,6], "c[d]": [7,8,9], "e": { "f": [10], "g": [11,12], "h": 13 } }) ), "a[]=1&a[]=2&a[]=3&b[]=4&b[]=5&b[]=6&c[d][]=7&c[d][]=8&c[d][]=9&e[f][]=10&e[g][]=11&e[g][]=12&e[h]=13", "Make sure params are not double-encoded." );
|
||||
|
||||
// #7945
|
||||
equal( jQuery.param({"jquery": "1.4.2"}), "jquery=1.4.2", "Check that object with a jQuery property get serialized correctly" );
|
||||
|
||||
jQuery.ajaxSetup({ traditional: true });
|
||||
|
||||
params = {foo:"bar", baz:42, quux:"All your base are belong to us"};
|
||||
params = {"foo":"bar", "baz":42, "quux":"All your base are belong to us"};
|
||||
equal( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" );
|
||||
|
||||
params = {someName: [1, 2, 3], regularThing: "blah" };
|
||||
params = {"someName": [1, 2, 3], "regularThing": "blah" };
|
||||
equal( jQuery.param(params), "someName=1&someName=2&someName=3®ularThing=blah", "with array" );
|
||||
|
||||
params = {foo: ["a", "b", "c"]};
|
||||
params = {"foo": ["a", "b", "c"]};
|
||||
equal( jQuery.param(params), "foo=a&foo=b&foo=c", "with array of strings" );
|
||||
|
||||
params = {"foo[]":["baz", 42, "All your base are belong to us"]};
|
||||
@ -1023,13 +1023,13 @@ test("jQuery.param()", function() {
|
||||
params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
|
||||
equal( jQuery.param(params), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=&l=0&m=cowboy+hat%3F", "huge structure" );
|
||||
|
||||
params = { a: [ 0, [ 1, 2 ], [ 3, [ 4, 5 ], [ 6 ] ], { b: [ 7, [ 8, 9 ], [ { c: 10, d: 11 } ], [ [ 12 ] ], [ [ [ 13 ] ] ], { e: { f: { g: [ 14, [ 15 ] ] } } }, 16 ] }, 17 ] };
|
||||
params = { "a": [ 0, [ 1, 2 ], [ 3, [ 4, 5 ], [ 6 ] ], { "b": [ 7, [ 8, 9 ], [ { "c": 10, d: 11 } ], [ [ 12 ] ], [ [ [ 13 ] ] ], { "e": { "f": { "g": [ 14, [ 15 ] ] } } }, 16 ] }, 17 ] };
|
||||
equal( jQuery.param(params), "a=0&a=1%2C2&a=3%2C4%2C5%2C6&a=%5Bobject+Object%5D&a=17", "nested arrays (not possible when jQuery.param.traditional == true)" );
|
||||
|
||||
params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
|
||||
equal( decodeURIComponent( jQuery.param(params,false) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=&i[]=10&i[]=11&j=true&k=false&l[]=&l[]=0&m=cowboy+hat?", "huge structure, forced not traditional" );
|
||||
|
||||
params = { param1: null };
|
||||
params = { "param1": null };
|
||||
equal( jQuery.param(params,false), "param1=", "Make sure that null params aren't traversed." );
|
||||
|
||||
params = {"test": {"length": 3, "foo": "bar"} };
|
||||
@ -1039,8 +1039,9 @@ test("jQuery.param()", function() {
|
||||
test("jQuery.param() Constructed prop values", function() {
|
||||
expect( 4 );
|
||||
|
||||
/** @constructor */
|
||||
function Record() {
|
||||
this.prop = "val";
|
||||
this["prop"] = "val";
|
||||
}
|
||||
|
||||
var MyString = String,
|
||||
@ -1057,7 +1058,7 @@ test("jQuery.param() Constructed prop values", function() {
|
||||
|
||||
// should allow non-native constructed objects
|
||||
params = { "test": new Record() };
|
||||
equal( jQuery.param( params, false ), jQuery.param({ "test": { prop: "val" } }), "Allow non-native constructed objects" );
|
||||
equal( jQuery.param( params, false ), jQuery.param({ "test": { "prop": "val" } }), "Allow non-native constructed objects" );
|
||||
});
|
||||
|
||||
test("synchronous request", function() {
|
||||
@ -1211,7 +1212,7 @@ test("load(String, Function) - check scripts", function() {
|
||||
stop();
|
||||
|
||||
var verifyEvaluation = function() {
|
||||
equal( foobar, "bar", "Check if script src was evaluated after load" );
|
||||
equal( window["foobar"], "bar", "Check if script src was evaluated after load" );
|
||||
equal( jQuery("#ap").html(), "bar", "Check if script evaluation has modified DOM");
|
||||
|
||||
start();
|
||||
@ -1219,7 +1220,7 @@ test("load(String, Function) - check scripts", function() {
|
||||
jQuery("#first").load(url("data/test.html"), function() {
|
||||
ok( jQuery("#first").html().match(/^html text/), "Check content after loading html" );
|
||||
equal( jQuery("#foo").html(), "foo", "Check if script evaluation has modified DOM");
|
||||
equal( testFoo, "foo", "Check if script was evaluated after load" );
|
||||
equal( window["testFoo"], "foo", "Check if script was evaluated after load" );
|
||||
setTimeout(verifyEvaluation, 600);
|
||||
});
|
||||
});
|
||||
@ -1230,7 +1231,7 @@ test("load(String, Function) - check file with only a script tag", function() {
|
||||
|
||||
jQuery("#first").load(url("data/test2.html"), function() {
|
||||
equal( jQuery("#foo").html(), "foo", "Check if script evaluation has modified DOM");
|
||||
equal( testFoo, "foo", "Check if script was evaluated after load" );
|
||||
equal( window["testFoo"], "foo", "Check if script was evaluated after load" );
|
||||
|
||||
start();
|
||||
});
|
||||
@ -1252,7 +1253,7 @@ test("load(String, Object, Function)", function() {
|
||||
expect(2);
|
||||
stop();
|
||||
|
||||
jQuery("<div />").load(url("data/params_html.php"), { foo: 3, bar: "ok" }, function() {
|
||||
jQuery("<div />").load(url("data/params_html.php"), { "foo": 3, "bar": "ok" }, function() {
|
||||
var $post = jQuery(this).find("#post");
|
||||
equal( $post.find("#foo").text(), "3", "Check if a hash of data is passed correctly");
|
||||
equal( $post.find("#bar").text(), "ok", "Check if a hash of data is passed correctly");
|
||||
@ -1274,11 +1275,11 @@ test("load(String, String, Function)", function() {
|
||||
|
||||
asyncTest("load() - data specified in ajaxSettings is merged in (#10524)", 1, function() {
|
||||
jQuery.ajaxSetup({
|
||||
data: { foo: "bar" }
|
||||
data: { "foo": "bar" }
|
||||
});
|
||||
|
||||
var data = {
|
||||
baz: 1
|
||||
"baz": 1
|
||||
};
|
||||
|
||||
jQuery("#foo").load( "data/echoQuery.php", data).ajaxComplete(function( event, jqXHR, options ) {
|
||||
@ -1520,7 +1521,7 @@ jQuery.each( [ "Same Domain", "Cross Domain" ] , function( crossDomain , label )
|
||||
crossDomain: crossDomain,
|
||||
jsonp: "callback",
|
||||
success: function(data){
|
||||
ok( data.data, "JSON results returned (GET, data obj callback)" );
|
||||
ok( data["data"], "JSON results returned (GET, data obj callback)" );
|
||||
plus();
|
||||
},
|
||||
error: function(data){
|
||||
@ -1529,9 +1530,9 @@ jQuery.each( [ "Same Domain", "Cross Domain" ] , function( crossDomain , label )
|
||||
}
|
||||
});
|
||||
|
||||
window.jsonpResults = function(data) {
|
||||
ok( data.data, "JSON results returned (GET, custom callback function)" );
|
||||
window.jsonpResults = undefined;
|
||||
window["jsonpResults"] = function(data) {
|
||||
ok( data["data"], "JSON results returned (GET, custom callback function)" );
|
||||
window["jsonpResults"] = undefined;
|
||||
plus();
|
||||
};
|
||||
|
||||
@ -1556,8 +1557,8 @@ jQuery.each( [ "Same Domain", "Cross Domain" ] , function( crossDomain , label )
|
||||
crossDomain: crossDomain,
|
||||
jsonpCallback: "functionToCleanUp",
|
||||
success: function(data){
|
||||
ok( data.data, "JSON results returned (GET, custom callback name to be cleaned up)" );
|
||||
strictEqual( window.functionToCleanUp, undefined, "Callback was removed (GET, custom callback name to be cleaned up)" );
|
||||
ok( data["data"], "JSON results returned (GET, custom callback name to be cleaned up)" );
|
||||
strictEqual( window["functionToCleanUp"], undefined, "Callback was removed (GET, custom callback name to be cleaned up)" );
|
||||
plus();
|
||||
var xhr;
|
||||
jQuery.ajax({
|
||||
@ -1572,7 +1573,7 @@ jQuery.each( [ "Same Domain", "Cross Domain" ] , function( crossDomain , label )
|
||||
});
|
||||
xhr.error(function() {
|
||||
ok( true, "Ajax error JSON (GET, custom callback name to be cleaned up)" );
|
||||
strictEqual( window.functionToCleanUp, undefined, "Callback was removed after early abort (GET, custom callback name to be cleaned up)" );
|
||||
strictEqual( window["functionToCleanUp"], undefined, "Callback was removed after early abort (GET, custom callback name to be cleaned up)" );
|
||||
plus();
|
||||
});
|
||||
},
|
||||
@ -1588,7 +1589,7 @@ jQuery.each( [ "Same Domain", "Cross Domain" ] , function( crossDomain , label )
|
||||
dataType: "jsonp",
|
||||
crossDomain: crossDomain,
|
||||
success: function(data){
|
||||
ok( data.data, "JSON results returned (POST, no callback)" );
|
||||
ok( data["data"], "JSON results returned (POST, no callback)" );
|
||||
plus();
|
||||
},
|
||||
error: function(data){
|
||||
@ -1604,7 +1605,7 @@ jQuery.each( [ "Same Domain", "Cross Domain" ] , function( crossDomain , label )
|
||||
dataType: "jsonp",
|
||||
crossDomain: crossDomain,
|
||||
success: function(data){
|
||||
ok( data.data, "JSON results returned (POST, data callback)" );
|
||||
ok( data["data"], "JSON results returned (POST, data callback)" );
|
||||
plus();
|
||||
},
|
||||
error: function(data){
|
||||
@ -1620,7 +1621,7 @@ jQuery.each( [ "Same Domain", "Cross Domain" ] , function( crossDomain , label )
|
||||
dataType: "jsonp",
|
||||
crossDomain: crossDomain,
|
||||
success: function(data){
|
||||
ok( data.data, "JSON results returned (POST, data obj callback)" );
|
||||
ok( data["data"], "JSON results returned (POST, data obj callback)" );
|
||||
plus();
|
||||
},
|
||||
error: function(data){
|
||||
@ -1653,7 +1654,7 @@ jQuery.each( [ "Same Domain", "Cross Domain" ] , function( crossDomain , label )
|
||||
plus();
|
||||
},
|
||||
success: function(data){
|
||||
ok( data.data, "JSON results returned (GET, custom callback name with no url manipulation)" );
|
||||
ok( data["data"], "JSON results returned (GET, custom callback name with no url manipulation)" );
|
||||
plus();
|
||||
},
|
||||
error: function(data){
|
||||
@ -1698,7 +1699,7 @@ test("jQuery.ajax() - script, Remote", function() {
|
||||
url: base + "data/test.js",
|
||||
dataType: "script",
|
||||
success: function(data){
|
||||
ok( foobar, "Script results returned (GET, no callback)" );
|
||||
ok( window["foobar"], "Script results returned (GET, no callback)" );
|
||||
start();
|
||||
}
|
||||
});
|
||||
@ -1716,7 +1717,7 @@ test("jQuery.ajax() - script, Remote with POST", function() {
|
||||
type: "POST",
|
||||
dataType: "script",
|
||||
success: function(data, status){
|
||||
ok( foobar, "Script results returned (POST, no callback)" );
|
||||
ok( window["foobar"], "Script results returned (POST, no callback)" );
|
||||
equal( status, "success", "Script results returned (POST, no callback)" );
|
||||
start();
|
||||
},
|
||||
@ -1739,7 +1740,7 @@ test("jQuery.ajax() - script, Remote with scheme-less URL", function() {
|
||||
url: base + "data/test.js",
|
||||
dataType: "script",
|
||||
success: function(data){
|
||||
ok( foobar, "Script results returned (GET, no callback)" );
|
||||
ok( window["foobar"], "Script results returned (GET, no callback)" );
|
||||
start();
|
||||
}
|
||||
});
|
||||
@ -1796,12 +1797,12 @@ test("jQuery.ajax() - script by content-type", function() {
|
||||
|
||||
jQuery.ajax({
|
||||
url: "data/script.php",
|
||||
data: { header: "script" }
|
||||
data: { "header": "script" }
|
||||
}),
|
||||
|
||||
jQuery.ajax({
|
||||
url: "data/script.php",
|
||||
data: { header: "ecma" }
|
||||
data: { "header": "ecma" }
|
||||
})
|
||||
|
||||
).always(function() {
|
||||
@ -1816,13 +1817,13 @@ test("jQuery.ajax() - json by content-type", function() {
|
||||
|
||||
jQuery.ajax({
|
||||
url: "data/json.php",
|
||||
data: { header: "json", json: "array" },
|
||||
data: { "header": "json", "json": "array" },
|
||||
success: function( json ) {
|
||||
ok( json.length >= 2, "Check length");
|
||||
equal( json[0].name, "John", "Check JSON: first, name" );
|
||||
equal( json[0].age, 21, "Check JSON: first, age" );
|
||||
equal( json[1].name, "Peter", "Check JSON: second, name" );
|
||||
equal( json[1].age, 25, "Check JSON: second, age" );
|
||||
equal( json[0]["name"], "John", "Check JSON: first, name" );
|
||||
equal( json[0]["age"], 21, "Check JSON: first, age" );
|
||||
equal( json[1]["name"], "Peter", "Check JSON: second, name" );
|
||||
equal( json[1]["age"], 25, "Check JSON: second, age" );
|
||||
start();
|
||||
}
|
||||
});
|
||||
@ -1835,18 +1836,18 @@ test("jQuery.ajax() - json by content-type disabled with options", function() {
|
||||
|
||||
jQuery.ajax({
|
||||
url: url("data/json.php"),
|
||||
data: { header: "json", json: "array" },
|
||||
data: { "header": "json", "json": "array" },
|
||||
contents: {
|
||||
json: false
|
||||
"json": false
|
||||
},
|
||||
success: function( text ) {
|
||||
equal( typeof text , "string" , "json wasn't auto-determined" );
|
||||
var json = jQuery.parseJSON( text );
|
||||
ok( json.length >= 2, "Check length");
|
||||
equal( json[0].name, "John", "Check JSON: first, name" );
|
||||
equal( json[0].age, 21, "Check JSON: first, age" );
|
||||
equal( json[1].name, "Peter", "Check JSON: second, name" );
|
||||
equal( json[1].age, 25, "Check JSON: second, age" );
|
||||
equal( json[0]["name"], "John", "Check JSON: first, name" );
|
||||
equal( json[0]["age"], 21, "Check JSON: first, age" );
|
||||
equal( json[1]["name"], "Peter", "Check JSON: second, name" );
|
||||
equal( json[1]["age"], 25, "Check JSON: second, age" );
|
||||
start();
|
||||
}
|
||||
});
|
||||
@ -1855,12 +1856,12 @@ test("jQuery.ajax() - json by content-type disabled with options", function() {
|
||||
test("jQuery.getJSON(String, Hash, Function) - JSON array", function() {
|
||||
expect(5);
|
||||
stop();
|
||||
jQuery.getJSON(url("data/json.php"), {json: "array"}, function(json) {
|
||||
jQuery.getJSON(url("data/json.php"), {"json": "array"}, function(json) {
|
||||
ok( json.length >= 2, "Check length");
|
||||
equal( json[0].name, "John", "Check JSON: first, name" );
|
||||
equal( json[0].age, 21, "Check JSON: first, age" );
|
||||
equal( json[1].name, "Peter", "Check JSON: second, name" );
|
||||
equal( json[1].age, 25, "Check JSON: second, age" );
|
||||
equal( json[0]["name"], "John", "Check JSON: first, name" );
|
||||
equal( json[0]["age"], 21, "Check JSON: first, age" );
|
||||
equal( json[1]["name"], "Peter", "Check JSON: second, name" );
|
||||
equal( json[1]["age"], 25, "Check JSON: second, age" );
|
||||
start();
|
||||
});
|
||||
});
|
||||
@ -1869,9 +1870,9 @@ test("jQuery.getJSON(String, Function) - JSON object", function() {
|
||||
expect(2);
|
||||
stop();
|
||||
jQuery.getJSON(url("data/json.php"), function(json) {
|
||||
if (json && json.data) {
|
||||
equal( json.data.lang, "en", "Check JSON: lang" );
|
||||
equal( json.data.length, 25, "Check JSON: length" );
|
||||
if (json && json["data"]) {
|
||||
equal( json["data"]["lang"], "en", "Check JSON: lang" );
|
||||
equal( json["data"].length, 25, "Check JSON: length" );
|
||||
}
|
||||
start();
|
||||
});
|
||||
@ -1944,7 +1945,7 @@ test("jQuery.post(String, Hash, Function) - simple with xml", function() {
|
||||
stop();
|
||||
var done = 0;
|
||||
|
||||
jQuery.post(url("data/name.php"), {xml: "5-2"}, function(xml){
|
||||
jQuery.post(url("data/name.php"), {"xml": "5-2"}, function(xml){
|
||||
jQuery("math", xml).each(function() {
|
||||
equal( jQuery("calculation", this).text(), "5-2", "Check for XML" );
|
||||
equal( jQuery("result", this).text(), "3", "Check for XML" );
|
||||
|
@ -23,18 +23,18 @@ test("jQuery.propFix integrity test", function() {
|
||||
// overwrites don't occur
|
||||
// This is simply for better code coverage and future proofing.
|
||||
var props = {
|
||||
tabindex: "tabIndex",
|
||||
readonly: "readOnly",
|
||||
"tabindex": "tabIndex",
|
||||
"readonly": "readOnly",
|
||||
"for": "htmlFor",
|
||||
"class": "className",
|
||||
maxlength: "maxLength",
|
||||
cellspacing: "cellSpacing",
|
||||
cellpadding: "cellPadding",
|
||||
rowspan: "rowSpan",
|
||||
colspan: "colSpan",
|
||||
usemap: "useMap",
|
||||
frameborder: "frameBorder",
|
||||
contenteditable: "contentEditable"
|
||||
"maxlength": "maxLength",
|
||||
"cellspacing": "cellSpacing",
|
||||
"cellpadding": "cellPadding",
|
||||
"rowspan": "rowSpan",
|
||||
"colspan": "colSpan",
|
||||
"usemap": "useMap",
|
||||
"frameborder": "frameBorder",
|
||||
"contenteditable": "contentEditable"
|
||||
};
|
||||
|
||||
if ( !jQuery.support.enctype ) {
|
||||
@ -155,14 +155,14 @@ test("attr(String, Function)", function() {
|
||||
test("attr(Hash)", function() {
|
||||
expect(3);
|
||||
var pass = true;
|
||||
jQuery("div").attr({foo: "baz", zoo: "ping"}).each(function(){
|
||||
jQuery("div").attr({"foo": "baz", "zoo": "ping"}).each(function(){
|
||||
if ( this.getAttribute("foo") != "baz" && this.getAttribute("zoo") != "ping" ) {
|
||||
pass = false;
|
||||
}
|
||||
});
|
||||
ok( pass, "Set Multiple Attributes" );
|
||||
equal( jQuery("#text1").attr({value: function() { return this.id; }})[0].value, "text1", "Set attribute to computed value #1" );
|
||||
equal( jQuery("#text1").attr({title: function(i) { return i; }}).attr("title"), "0", "Set attribute to computed value #2");
|
||||
equal( jQuery("#text1").attr({"value": function() { return this["id"]; }})[0].value, "text1", "Set attribute to computed value #1" );
|
||||
equal( jQuery("#text1").attr({"title": function(i) { return i; }}).attr("title"), "0", "Set attribute to computed value #2");
|
||||
});
|
||||
|
||||
test("attr(String, Object)", function() {
|
||||
@ -288,11 +288,11 @@ test("attr(String, Object)", function() {
|
||||
var table = jQuery("#table").append("<tr><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr>"),
|
||||
td = table.find("td:first");
|
||||
td.attr("rowspan", "2");
|
||||
equal( td[0].rowSpan, 2, "Check rowspan is correctly set" );
|
||||
equal( td[0]["rowSpan"], 2, "Check rowspan is correctly set" );
|
||||
td.attr("colspan", "2");
|
||||
equal( td[0].colSpan, 2, "Check colspan is correctly set" );
|
||||
equal( td[0]["colSpan"], 2, "Check colspan is correctly set" );
|
||||
table.attr("cellspacing", "2");
|
||||
equal( table[0].cellSpacing, "2", "Check cellspacing is correctly set" );
|
||||
equal( table[0]["cellSpacing"], "2", "Check cellspacing is correctly set" );
|
||||
|
||||
equal( jQuery("#area1").attr("value"), "foobar", "Value attribute retrieves the property for backwards compatibility." );
|
||||
|
||||
@ -381,26 +381,26 @@ test("attr(jquery_method)", function(){
|
||||
|
||||
if ( jQuery.fn.width ) {
|
||||
expected += 2;
|
||||
attrObj.width = 10;
|
||||
attrObj["width"] = 10;
|
||||
}
|
||||
|
||||
if ( jQuery.fn.offset ) {
|
||||
expected += 2;
|
||||
attrObj.offset = { top: 1, left: 0 };
|
||||
attrObj["offset"] = { "top": 1, "left": 0 };
|
||||
}
|
||||
|
||||
if ( jQuery.css ) {
|
||||
expected += 3;
|
||||
attrObj.css = { paddingLeft: 1, paddingRight: 1 };
|
||||
attrObj["css"] = { "paddingLeft": 1, "paddingRight": 1 };
|
||||
}
|
||||
|
||||
expect( expected );
|
||||
|
||||
// one at a time
|
||||
$elem.attr( { html: "foo" }, true );
|
||||
$elem.attr( { "html": "foo" }, true );
|
||||
equal( elem.innerHTML, "foo", "attr(html)" );
|
||||
|
||||
$elem.attr( { text: "bar" }, true );
|
||||
$elem.attr( { "text": "bar" }, true );
|
||||
equal( elem.innerHTML, "bar", "attr(text)" );
|
||||
|
||||
// Multiple attributes
|
||||
@ -409,7 +409,7 @@ test("attr(jquery_method)", function(){
|
||||
if ( jQuery.fn.width ) {
|
||||
equal( elem.style.width, "10px", "attr({width:})" );
|
||||
|
||||
$elem.attr( { height: 10 }, true );
|
||||
$elem.attr( { "height": 10 }, true );
|
||||
equal( elem.style.height, "10px", "attr(height)" );
|
||||
}
|
||||
|
||||
@ -424,7 +424,7 @@ test("attr(jquery_method)", function(){
|
||||
equal( elem.style.paddingLeft, "1px", "attr({css:})" );
|
||||
equal( elem.style.paddingRight, "1px", "attr({css:})" );
|
||||
|
||||
$elem.attr( { css: { color: "red" } }, true );
|
||||
$elem.attr( { "css": { "color": "red" } }, true );
|
||||
ok( /^(#ff0000|red)$/i.test( elem.style.color ), "attr(css)" );
|
||||
}
|
||||
});
|
||||
@ -579,9 +579,9 @@ test("prop(String, Object)", function() {
|
||||
$body = jQuery( body );
|
||||
|
||||
ok( $body.prop("nextSibling") === null, "Make sure a null expando returns null" );
|
||||
body.foo = "bar";
|
||||
body["foo"] = "bar";
|
||||
equal( $body.prop("foo"), "bar", "Make sure the expando is preferred over the dom attribute" );
|
||||
body.foo = undefined;
|
||||
body["foo"] = undefined;
|
||||
ok( $body.prop("foo") === undefined, "Make sure the expando is preferred over the dom attribute, even if undefined" );
|
||||
|
||||
var select = document.createElement("select"), optgroup = document.createElement("optgroup"), option = document.createElement("option");
|
||||
@ -673,17 +673,17 @@ test("removeProp(String)", function() {
|
||||
textNode = document.createTextNode("some text"),
|
||||
obj = {};
|
||||
|
||||
strictEqual( jQuery( "#firstp" ).prop( "nonexisting", "foo" ).removeProp( "nonexisting" )[0].nonexisting, undefined, "removeprop works correctly on DOM element nodes" );
|
||||
strictEqual( jQuery( "#firstp" ).prop( "nonexisting", "foo" ).removeProp( "nonexisting" )[0]["nonexisting"], undefined, "removeprop works correctly on DOM element nodes" );
|
||||
|
||||
jQuery.each( [document, obj], function( i, ele ) {
|
||||
var $ele = jQuery( ele );
|
||||
$ele.prop( "nonexisting", "foo" ).removeProp( "nonexisting" );
|
||||
strictEqual( ele.nonexisting, undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." );
|
||||
strictEqual( ele["nonexisting"], undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." );
|
||||
});
|
||||
jQuery.each( [commentNode, textNode, attributeNode], function( i, ele ) {
|
||||
var $ele = jQuery( ele );
|
||||
$ele.prop( "nonexisting", "foo" ).removeProp( "nonexisting" );
|
||||
strictEqual( ele.nonexisting, undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." );
|
||||
strictEqual( ele["nonexisting"], undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." );
|
||||
});
|
||||
});
|
||||
|
||||
@ -898,7 +898,7 @@ test("val(select) after form.reset() (Bug #2551)", function() {
|
||||
|
||||
jQuery("#kkk").val( "gf" );
|
||||
|
||||
document.kk.reset();
|
||||
document["kk"].reset();
|
||||
|
||||
equal( jQuery("#kkk")[0].value, "cf", "Check value of select after form reset." );
|
||||
equal( jQuery("#kkk").val(), "cf", "Check value of select after form reset." );
|
||||
|
@ -209,14 +209,14 @@ test( "jQuery.Callbacks( options ) - options are copied", function() {
|
||||
expect( 1 );
|
||||
|
||||
var options = {
|
||||
unique: true
|
||||
"unique": true
|
||||
},
|
||||
cb = jQuery.Callbacks( options ),
|
||||
count = 0,
|
||||
fn = function() {
|
||||
ok( !( count++ ), "called once" );
|
||||
};
|
||||
options.unique = false;
|
||||
options["unique"] = false;
|
||||
cb.add( fn, fn );
|
||||
cb.fire();
|
||||
});
|
||||
|
@ -26,28 +26,28 @@ test("jQuery()", function() {
|
||||
img = jQuery("<img/>"),
|
||||
div = jQuery("<div/><hr/><code/><b/>"),
|
||||
exec = false,
|
||||
long = "",
|
||||
lng = "",
|
||||
expected = 26,
|
||||
attrObj = {
|
||||
click: function() { ok( exec, "Click executed." ); },
|
||||
text: "test",
|
||||
"click": function() { ok( exec, "Click executed." ); },
|
||||
"text": "test",
|
||||
"class": "test2",
|
||||
id: "test3"
|
||||
"id": "test3"
|
||||
};
|
||||
|
||||
if ( jQuery.fn.width ) {
|
||||
expected++;
|
||||
attrObj.width = 10;
|
||||
attrObj["width"] = 10;
|
||||
}
|
||||
|
||||
if ( jQuery.fn.offset ) {
|
||||
expected++;
|
||||
attrObj.offset = { top: 1, left: 1 };
|
||||
attrObj["offset"] = { "top": 1, "left": 1 };
|
||||
}
|
||||
|
||||
if ( jQuery.css ) {
|
||||
expected += 2;
|
||||
attrObj.css = { paddingLeft: 1, paddingRight: 1 };
|
||||
attrObj["css"] = { "paddingLeft": 1, "paddingRight": 1 };
|
||||
}
|
||||
|
||||
expect( expected );
|
||||
@ -135,11 +135,11 @@ test("jQuery()", function() {
|
||||
equal( jQuery(" a<div/>b ").length, 1, "Make sure whitespace and other characters are trimmed." );
|
||||
|
||||
for ( i = 0; i < 128; i++ ) {
|
||||
long += "12345678";
|
||||
lng += "12345678";
|
||||
}
|
||||
|
||||
equal( jQuery(" <div>" + long + "</div> ").length, 1, "Make sure whitespace is trimmed on long strings." );
|
||||
equal( jQuery(" a<div>" + long + "</div>b ").length, 1, "Make sure whitespace and other characters are trimmed on long strings." );
|
||||
equal( jQuery(" <div>" + lng + "</div> ").length, 1, "Make sure whitespace is trimmed on long strings." );
|
||||
equal( jQuery(" a<div>" + lng + "</div>b ").length, 1, "Make sure whitespace and other characters are trimmed on long strings." );
|
||||
});
|
||||
|
||||
test("selector state", function() {
|
||||
@ -242,17 +242,17 @@ test("noConflict", function() {
|
||||
var $$ = jQuery;
|
||||
|
||||
equal( jQuery, jQuery.noConflict(), "noConflict returned the jQuery object" );
|
||||
equal( jQuery, $$, "Make sure jQuery wasn't touched." );
|
||||
equal( $, original$, "Make sure $ was reverted." );
|
||||
equal( window["jQuery"], $$, "Make sure jQuery wasn't touched." );
|
||||
equal( window["$"], original$, "Make sure $ was reverted." );
|
||||
|
||||
jQuery = $ = $$;
|
||||
|
||||
equal( jQuery.noConflict(true), $$, "noConflict returned the jQuery object" );
|
||||
equal( jQuery, originaljQuery, "Make sure jQuery was reverted." );
|
||||
equal( $, original$, "Make sure $ was reverted." );
|
||||
equal( window["jQuery"], originaljQuery, "Make sure jQuery was reverted." );
|
||||
equal( window["$"], original$, "Make sure $ was reverted." );
|
||||
ok( $$("#qunit-fixture").html("test"), "Make sure that jQuery still works." );
|
||||
|
||||
jQuery = $$;
|
||||
window["jQuery"] = jQuery = $$;
|
||||
});
|
||||
|
||||
test("trim", function() {
|
||||
@ -321,17 +321,20 @@ asyncTest("isPlainObject", function() {
|
||||
// Instantiated objects shouldn't be matched
|
||||
ok(!jQuery.isPlainObject(new Date()), "new Date");
|
||||
|
||||
var fn = function(){};
|
||||
var fnplain = function(){};
|
||||
|
||||
// Functions shouldn't be matched
|
||||
ok(!jQuery.isPlainObject(fn), "fn");
|
||||
ok(!jQuery.isPlainObject(fnplain), "fn");
|
||||
|
||||
/** @constructor */
|
||||
var fn = function() {};
|
||||
|
||||
// Again, instantiated objects shouldn't be matched
|
||||
ok(!jQuery.isPlainObject(new fn()), "new fn (no methods)");
|
||||
|
||||
// Makes the function a little more realistic
|
||||
// (and harder to detect, incidentally)
|
||||
fn.prototype = {someMethod: function(){}};
|
||||
fn.prototype["someMethod"] = function(){};
|
||||
|
||||
// Again, instantiated objects shouldn't be matched
|
||||
ok(!jQuery.isPlainObject(new fn()), "new fn");
|
||||
@ -463,7 +466,7 @@ test( "isNumeric", function() {
|
||||
expect( 36 );
|
||||
|
||||
var t = jQuery.isNumeric,
|
||||
Traditionalists = function(n) {
|
||||
Traditionalists = /** @constructor */ function(n) {
|
||||
this.value = n;
|
||||
this.toString = function(){
|
||||
return String(this.value);
|
||||
@ -543,17 +546,17 @@ test("XSS via location.hash", function() {
|
||||
expect(1);
|
||||
|
||||
stop();
|
||||
jQuery._check9521 = function(x){
|
||||
jQuery["_check9521"] = function(x){
|
||||
ok( x, "script called from #id-like selector with inline handler" );
|
||||
jQuery("#check9521").remove();
|
||||
delete jQuery._check9521;
|
||||
delete jQuery["_check9521"];
|
||||
start();
|
||||
};
|
||||
try {
|
||||
// This throws an error because it's processed like an id
|
||||
jQuery( '#<img id="check9521" src="no-such-.gif" onerror="jQuery._check9521(false)">' ).appendTo("#qunit-fixture");
|
||||
} catch (err) {
|
||||
jQuery._check9521(true);
|
||||
jQuery["_check9521"](true);
|
||||
}
|
||||
});
|
||||
|
||||
@ -588,12 +591,12 @@ test("jQuery('html')", function() {
|
||||
expect( 18 );
|
||||
|
||||
QUnit.reset();
|
||||
jQuery.foo = false;
|
||||
jQuery["foo"] = false;
|
||||
var s = jQuery("<script>jQuery.foo='test';</script>")[0];
|
||||
ok( s, "Creating a script" );
|
||||
ok( !jQuery.foo, "Make sure the script wasn't executed prematurely" );
|
||||
ok( !jQuery["foo"], "Make sure the script wasn't executed prematurely" );
|
||||
jQuery("body").append("<script>jQuery.foo='test';</script>");
|
||||
ok( jQuery.foo, "Executing a scripts contents in the right context" );
|
||||
ok( jQuery["foo"], "Executing a scripts contents in the right context" );
|
||||
|
||||
// Test multi-line HTML
|
||||
var div = jQuery("<div>\r\nsome text\n<p>some p</p>\nmore text\r\n</div>")[0];
|
||||
@ -797,7 +800,7 @@ test("map()", function() {
|
||||
|
||||
var keys, values, scripts, nonsense, mapped, flat;
|
||||
//for #2616
|
||||
keys = jQuery.map( {a:1,b:2}, function( v, k ){
|
||||
keys = jQuery.map( {"a":1,"b":2}, function( v, k ){
|
||||
return k;
|
||||
});
|
||||
equal( keys.join(""), "ab", "Map the keys from a hash to an array" );
|
||||
@ -849,23 +852,23 @@ test("jQuery.merge()", function() {
|
||||
|
||||
// After fixing #5527
|
||||
deepEqual( parse([], [null, undefined]), [null, undefined], "Second array including null and undefined values");
|
||||
deepEqual( parse({length:0}, [1,2]), {length:2, 0:1, 1:2}, "First array like");
|
||||
deepEqual( parse({"length":0}, [1,2]), {length:2, 0:1, 1:2}, "First array like");
|
||||
});
|
||||
|
||||
test("jQuery.extend(Object, Object)", function() {
|
||||
expect(28);
|
||||
|
||||
var settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
|
||||
options = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
|
||||
optionsCopy = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
|
||||
merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" },
|
||||
deep1 = { foo: { bar: true } },
|
||||
deep1copy = { foo: { bar: true } },
|
||||
deep2 = { foo: { baz: true }, foo2: document },
|
||||
deep2copy = { foo: { baz: true }, foo2: document },
|
||||
deepmerged = { foo: { bar: true, baz: true }, foo2: document },
|
||||
var settings = { "xnumber1": 5, "xnumber2": 7, "xstring1": "peter", "xstring2": "pan" },
|
||||
options = { "xnumber2": 1, "xstring2": "x", "xxx": "newstring" },
|
||||
optionsCopy = { "xnumber2": 1, "xstring2": "x", "xxx": "newstring" },
|
||||
merged = { "xnumber1": 5, "xnumber2": 1, "xstring1": "peter", "xstring2": "x", "xxx": "newstring" },
|
||||
deep1 = { "foo": { "bar": true } },
|
||||
deep1copy = { "foo": { "bar": true } },
|
||||
deep2 = { "foo": { "baz": true }, "foo2": document },
|
||||
deep2copy = { "foo": { "baz": true }, "foo2": document },
|
||||
deepmerged = { "foo": { "bar": true, "baz": true }, "foo2": document },
|
||||
arr = [1, 2, 3],
|
||||
nestedarray = { arr: arr };
|
||||
nestedarray = { "arr": arr };
|
||||
|
||||
jQuery.extend(settings, options);
|
||||
deepEqual( settings, merged, "Check if extended: settings must be extended" );
|
||||
@ -876,52 +879,53 @@ test("jQuery.extend(Object, Object)", function() {
|
||||
deepEqual( options, optionsCopy, "Check if not modified: options must not be modified" );
|
||||
|
||||
jQuery.extend(true, deep1, deep2);
|
||||
deepEqual( deep1.foo, deepmerged.foo, "Check if foo: settings must be extended" );
|
||||
deepEqual( deep2.foo, deep2copy.foo, "Check if not deep2: options must not be modified" );
|
||||
equal( deep1.foo2, document, "Make sure that a deep clone was not attempted on the document" );
|
||||
deepEqual( deep1["foo"], deepmerged["foo"], "Check if foo: settings must be extended" );
|
||||
deepEqual( deep2["foo"], deep2copy["foo"], "Check if not deep2: options must not be modified" );
|
||||
equal( deep1["foo2"], document, "Make sure that a deep clone was not attempted on the document" );
|
||||
|
||||
ok( jQuery.extend(true, {}, nestedarray).arr !== arr, "Deep extend of object must clone child array" );
|
||||
ok( jQuery.extend(true, {}, nestedarray)["arr"] !== arr, "Deep extend of object must clone child array" );
|
||||
|
||||
// #5991
|
||||
ok( jQuery.isArray( jQuery.extend(true, { arr: {} }, nestedarray).arr ), "Cloned array heve to be an Array" );
|
||||
ok( jQuery.isPlainObject( jQuery.extend(true, { arr: arr }, { arr: {} }).arr ), "Cloned object heve to be an plain object" );
|
||||
ok( jQuery.isArray( jQuery.extend(true, { "arr": {} }, nestedarray)["arr"] ), "Cloned array heve to be an Array" );
|
||||
ok( jQuery.isPlainObject( jQuery.extend(true, { "arr": arr }, { "arr": {} })["arr"] ), "Cloned object heve to be an plain object" );
|
||||
|
||||
var empty = {};
|
||||
var optionsWithLength = { foo: { length: -1 } };
|
||||
var optionsWithLength = { "foo": { "length": -1 } };
|
||||
jQuery.extend(true, empty, optionsWithLength);
|
||||
deepEqual( empty.foo, optionsWithLength.foo, "The length property must copy correctly" );
|
||||
deepEqual( empty["foo"], optionsWithLength["foo"], "The length property must copy correctly" );
|
||||
|
||||
empty = {};
|
||||
var optionsWithDate = { foo: { date: new Date() } };
|
||||
var optionsWithDate = { "foo": { "date": new Date() } };
|
||||
jQuery.extend(true, empty, optionsWithDate);
|
||||
deepEqual( empty.foo, optionsWithDate.foo, "Dates copy correctly" );
|
||||
deepEqual( empty["foo"], optionsWithDate["foo"], "Dates copy correctly" );
|
||||
|
||||
/** @constructor */
|
||||
var myKlass = function() {};
|
||||
var customObject = new myKlass();
|
||||
var optionsWithCustomObject = { foo: { date: customObject } };
|
||||
var optionsWithCustomObject = { "foo": { "date": customObject } };
|
||||
empty = {};
|
||||
jQuery.extend(true, empty, optionsWithCustomObject);
|
||||
ok( empty.foo && empty.foo.date === customObject, "Custom objects copy correctly (no methods)" );
|
||||
ok( empty["foo"] && empty["foo"]["date"] === customObject, "Custom objects copy correctly (no methods)" );
|
||||
|
||||
// Makes the class a little more realistic
|
||||
myKlass.prototype = { someMethod: function(){} };
|
||||
myKlass.prototype = { "someMethod": function(){} };
|
||||
empty = {};
|
||||
jQuery.extend(true, empty, optionsWithCustomObject);
|
||||
ok( empty.foo && empty.foo.date === customObject, "Custom objects copy correctly" );
|
||||
ok( empty["foo"] && empty["foo"]["date"] === customObject, "Custom objects copy correctly" );
|
||||
|
||||
var MyNumber = Number;
|
||||
var ret = jQuery.extend(true, { foo: 4 }, { foo: new MyNumber(5) } );
|
||||
var ret = jQuery.extend(true, { "foo": 4 }, { "foo": new MyNumber(5) } );
|
||||
ok( ret.foo == 5, "Wrapped numbers copy correctly" );
|
||||
|
||||
var nullUndef;
|
||||
nullUndef = jQuery.extend({}, options, { xnumber2: null });
|
||||
ok( nullUndef.xnumber2 === null, "Check to make sure null values are copied");
|
||||
nullUndef = jQuery.extend({}, options, { "xnumber2": null });
|
||||
ok( nullUndef["xnumber2"] === null, "Check to make sure null values are copied");
|
||||
|
||||
nullUndef = jQuery.extend({}, options, { xnumber2: undefined });
|
||||
ok( nullUndef.xnumber2 === options.xnumber2, "Check to make sure undefined values are not copied");
|
||||
nullUndef = jQuery.extend({}, options, { "xnumber2": undefined });
|
||||
ok( nullUndef["xnumber2"] === options["xnumber2"], "Check to make sure undefined values are not copied");
|
||||
|
||||
nullUndef = jQuery.extend({}, options, { xnumber0: null });
|
||||
ok( nullUndef.xnumber0 === null, "Check to make sure null values are inserted");
|
||||
nullUndef = jQuery.extend({}, options, { "xnumber0": null });
|
||||
ok( nullUndef["xnumber0"] === null, "Check to make sure null values are inserted");
|
||||
|
||||
var target = {};
|
||||
var recursive = { foo:target, bar:5 };
|
||||
@ -1014,7 +1018,7 @@ test("jQuery.makeArray", function(){
|
||||
|
||||
equal( jQuery.makeArray(document.getElementsByName("PWD")).slice(0,1)[0].name, "PWD", "Pass makeArray a nodelist" );
|
||||
|
||||
equal( (function(){ return jQuery.makeArray(arguments); })(1,2).join(""), "12", "Pass makeArray an arguments array" );
|
||||
equal( (function(arg1, arg2){ return jQuery.makeArray(arguments); })(1,2).join(""), "12", "Pass makeArray an arguments array" );
|
||||
|
||||
equal( jQuery.makeArray([1,2,3]).join(""), "123", "Pass makeArray a real array" );
|
||||
|
||||
@ -1094,7 +1098,7 @@ test("jQuery.proxy", function(){
|
||||
jQuery.proxy( test3, null, "pre-applied" )( "normal" );
|
||||
|
||||
// Test old syntax
|
||||
var test4 = { meth: function( a ){ equal( a, "boom", "Ensure old syntax works." ); } };
|
||||
var test4 = { "meth": function( a ){ equal( a, "boom", "Ensure old syntax works." ); } };
|
||||
jQuery.proxy( test4, "meth" )( "boom" );
|
||||
});
|
||||
|
||||
@ -1192,48 +1196,48 @@ test("jQuery.sub() - Static Methods", function(){
|
||||
expect(18);
|
||||
var Subclass = jQuery.sub();
|
||||
Subclass.extend({
|
||||
topLevelMethod: function() {return this.debug;},
|
||||
debug: false,
|
||||
config: {
|
||||
locale: "en_US"
|
||||
"topLevelMethod": function() {return this.debug;},
|
||||
"debug": false,
|
||||
"config": {
|
||||
"locale": "en_US"
|
||||
},
|
||||
setup: function(config) {
|
||||
this.extend(true, this.config, config);
|
||||
"setup": function(config) {
|
||||
this.extend(true, this["config"], config);
|
||||
}
|
||||
});
|
||||
Subclass.fn.extend({subClassMethod: function() { return this;}});
|
||||
Subclass.fn.extend({"subClassMethod": function() { return this;}});
|
||||
|
||||
//Test Simple Subclass
|
||||
ok(Subclass.topLevelMethod() === false, "Subclass.topLevelMethod thought debug was true");
|
||||
ok(Subclass.config.locale == "en_US", Subclass.config.locale + " is wrong!");
|
||||
deepEqual(Subclass.config.test, undefined, "Subclass.config.test is set incorrectly");
|
||||
ok(Subclass["topLevelMethod"]() === false, "Subclass.topLevelMethod thought debug was true");
|
||||
ok(Subclass["config"]["locale"] == "en_US", Subclass["config"]["locale"] + " is wrong!");
|
||||
deepEqual(Subclass["config"]["test"], undefined, "Subclass.config.test is set incorrectly");
|
||||
equal(jQuery.ajax, Subclass.ajax, "The subclass failed to get all top level methods");
|
||||
|
||||
//Create a SubSubclass
|
||||
var SubSubclass = Subclass.sub();
|
||||
|
||||
//Make Sure the SubSubclass inherited properly
|
||||
ok(SubSubclass.topLevelMethod() === false, "SubSubclass.topLevelMethod thought debug was true");
|
||||
ok(SubSubclass.config.locale == "en_US", SubSubclass.config.locale + " is wrong!");
|
||||
deepEqual(SubSubclass.config.test, undefined, "SubSubclass.config.test is set incorrectly");
|
||||
ok(SubSubclass["topLevelMethod"]() === false, "SubSubclass.topLevelMethod thought debug was true");
|
||||
ok(SubSubclass["config"]["locale"] == "en_US", SubSubclass["config"]["locale"] + " is wrong!");
|
||||
deepEqual(SubSubclass["config"]["test"], undefined, "SubSubclass.config.test is set incorrectly");
|
||||
equal(jQuery.ajax, SubSubclass.ajax, "The subsubclass failed to get all top level methods");
|
||||
|
||||
//Modify The Subclass and test the Modifications
|
||||
SubSubclass.fn.extend({subSubClassMethod: function() { return this;}});
|
||||
SubSubclass.setup({locale: "es_MX", test: "worked"});
|
||||
SubSubclass.debug = true;
|
||||
SubSubclass.fn.extend({"subSubClassMethod": function() { return this;}});
|
||||
SubSubclass["setup"]({"locale": "es_MX", "test": "worked"});
|
||||
SubSubclass["debug"] = true;
|
||||
SubSubclass.ajax = function() {return false;};
|
||||
ok(SubSubclass.topLevelMethod(), "SubSubclass.topLevelMethod thought debug was false");
|
||||
deepEqual(SubSubclass(document).subClassMethod, Subclass.fn.subClassMethod, "Methods Differ!");
|
||||
ok(SubSubclass.config.locale == "es_MX", SubSubclass.config.locale + " is wrong!");
|
||||
ok(SubSubclass.config.test == "worked", "SubSubclass.config.test is set incorrectly");
|
||||
ok(SubSubclass["topLevelMethod"](), "SubSubclass.topLevelMethod thought debug was false");
|
||||
deepEqual(SubSubclass(document)["subClassMethod"], Subclass.fn["subClassMethod"], "Methods Differ!");
|
||||
ok(SubSubclass["config"]["locale"] == "es_MX", SubSubclass["config"]["locale"] + " is wrong!");
|
||||
ok(SubSubclass["config"]["test"] == "worked", "SubSubclass.config.test is set incorrectly");
|
||||
notEqual(jQuery.ajax, SubSubclass.ajax, "The subsubclass failed to get all top level methods");
|
||||
|
||||
//This shows that the modifications to the SubSubClass did not bubble back up to it's superclass
|
||||
ok(Subclass.topLevelMethod() === false, "Subclass.topLevelMethod thought debug was true");
|
||||
ok(Subclass.config.locale == "en_US", Subclass.config.locale + " is wrong!");
|
||||
deepEqual(Subclass.config.test, undefined, "Subclass.config.test is set incorrectly");
|
||||
deepEqual(Subclass(document).subSubClassMethod, undefined, "subSubClassMethod set incorrectly");
|
||||
ok(Subclass["topLevelMethod"]() === false, "Subclass.topLevelMethod thought debug was true");
|
||||
ok(Subclass["config"]["locale"] == "en_US", Subclass["config"]["locale"] + " is wrong!");
|
||||
deepEqual(Subclass["config"]["test"], undefined, "Subclass.config.test is set incorrectly");
|
||||
deepEqual(Subclass(document)["subSubClassMethod"], undefined, "subSubClassMethod set incorrectly");
|
||||
equal(jQuery.ajax, Subclass.ajax, "The subclass failed to get all top level methods");
|
||||
});
|
||||
|
||||
@ -1256,35 +1260,31 @@ test("jQuery.sub() - .fn Methods", function(){
|
||||
"<div></div>"
|
||||
];
|
||||
|
||||
methods = [ // all methods that return a new jQuery instance
|
||||
["eq", 1],
|
||||
["add", document],
|
||||
["end"],
|
||||
["has"],
|
||||
["closest", "div"],
|
||||
["filter", document],
|
||||
["find", "div"]
|
||||
];
|
||||
|
||||
contexts = [undefined, document, jQueryDocument];
|
||||
|
||||
jQuery.expandedEach = jQuery.each;
|
||||
jQuery.each(selectors, function(i, selector){
|
||||
|
||||
jQuery.each(methods, function(){
|
||||
method = this[0];
|
||||
arg = this[1];
|
||||
|
||||
jQuery.expandedEach({ // all methods that return a new jQuery instance
|
||||
"eq": 1 ,
|
||||
"add": document,
|
||||
"end": undefined,
|
||||
"has": undefined,
|
||||
"closest": "div",
|
||||
"filter": document,
|
||||
"find": "div"
|
||||
}, function(method, arg){
|
||||
jQuery.each(contexts, function(i, context){
|
||||
|
||||
description = "(\""+selector+"\", "+context+")."+method+"("+(arg||"")+")";
|
||||
|
||||
deepEqual(
|
||||
jQuery(selector, context)[method](arg).subclassMethod, undefined,
|
||||
"jQuery"+description+" doesn't have Subclass methods"
|
||||
(function(var_args){ return jQuery.fn[method].apply(jQuery(selector, context), arguments).subclassMethod; })(arg),
|
||||
undefined, "jQuery"+description+" doesn't have Subclass methods"
|
||||
);
|
||||
deepEqual(
|
||||
jQuery(selector, context)[method](arg).subclassSubclassMethod, undefined,
|
||||
"jQuery"+description+" doesn't have SubclassSubclass methods"
|
||||
(function(var_args){ return jQuery.fn[method].apply(jQuery(selector, context), arguments).subclassSubclassMethod; })(arg),
|
||||
undefined, "jQuery"+description+" doesn't have SubclassSubclass methods"
|
||||
);
|
||||
deepEqual(
|
||||
Subclass(selector, context)[method](arg).subclassMethod, Subclass.fn.subclassMethod,
|
||||
|
@ -10,11 +10,11 @@ test("css(String|Hash)", function() {
|
||||
ok( jQuery("#nothiddendiv").is(":visible"), "Modifying CSS display: Assert element is visible" );
|
||||
jQuery("#nothiddendiv").css({ display: "none" });
|
||||
ok( !jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is hidden" );
|
||||
var $child = jQuery("#nothiddendivchild").css({ width: "20%", height: "20%" });
|
||||
var $child = jQuery("#nothiddendivchild").css({ "width": "20%", "height": "20%" });
|
||||
notEqual( $child.css("width"), "20px", "Retrieving a width percentage on the child of a hidden div returns percentage" );
|
||||
notEqual( $child.css("height"), "20px", "Retrieving a height percentage on the child of a hidden div returns percentage" );
|
||||
|
||||
jQuery("#nothiddendiv").css({display: "block"});
|
||||
jQuery("#nothiddendiv").css({"display": "block"});
|
||||
ok( jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is visible");
|
||||
ok( jQuery(window).is(":visible"), "Calling is(':visible') on window does not throw an error in IE.");
|
||||
ok( jQuery(document).is(":visible"), "Calling is(':visible') on document does not throw an error in IE.");
|
||||
@ -26,7 +26,7 @@ test("css(String|Hash)", function() {
|
||||
equal( div.css("width"), "0px", "Width on disconnected node." );
|
||||
equal( div.css("height"), "0px", "Height on disconnected node." );
|
||||
|
||||
div.css({ width: 4, height: 4 });
|
||||
div.css({ "width": 4, "height": 4 });
|
||||
|
||||
equal( div.css("width"), "4px", "Width on disconnected node." );
|
||||
equal( div.css("height"), "4px", "Height on disconnected node." );
|
||||
@ -40,10 +40,10 @@ test("css(String|Hash)", function() {
|
||||
div2.remove();
|
||||
|
||||
// handle negative numbers by setting to zero #11604
|
||||
jQuery("#nothiddendiv").css( {width: 1, height: 1} );
|
||||
jQuery("#nothiddendiv").css( {"width": 1, "height": 1} );
|
||||
|
||||
var width = parseFloat(jQuery("#nothiddendiv").css("width")), height = parseFloat(jQuery("#nothiddendiv").css("height"));
|
||||
jQuery("#nothiddendiv").css({ overflow:"hidden", width: -1, height: -1 });
|
||||
jQuery("#nothiddendiv").css({ "overflow":"hidden", "width": -1, "height": -1 });
|
||||
equal( parseFloat(jQuery("#nothiddendiv").css("width")), 0, "Test negative width set to 0");
|
||||
equal( parseFloat(jQuery("#nothiddendiv").css("height")), 0, "Test negative height set to 0");
|
||||
|
||||
@ -54,17 +54,17 @@ test("css(String|Hash)", function() {
|
||||
jQuery("#floatTest").css({"font-size": "30px"});
|
||||
equal( jQuery("#floatTest").css("font-size"), "30px", "Modified CSS font-size: Assert font-size is 30px");
|
||||
jQuery.each("0,0.25,0.5,0.75,1".split(","), function(i, n) {
|
||||
jQuery("#foo").css({opacity: n});
|
||||
jQuery("#foo").css({"opacity": n});
|
||||
|
||||
equal( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
|
||||
jQuery("#foo").css({opacity: parseFloat(n)});
|
||||
jQuery("#foo").css({"opacity": parseFloat(n)});
|
||||
equal( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
|
||||
});
|
||||
jQuery("#foo").css({opacity: ""});
|
||||
jQuery("#foo").css({"opacity": ""});
|
||||
equal( jQuery("#foo").css("opacity"), "1", "Assert opacity is 1 when set to an empty String" );
|
||||
|
||||
equal( jQuery("#empty").css("opacity"), "0", "Assert opacity is accessible via filter property set in stylesheet in IE" );
|
||||
jQuery("#empty").css({ opacity: "1" });
|
||||
jQuery("#empty").css({ "opacity": "1" });
|
||||
equal( jQuery("#empty").css("opacity"), "1", "Assert opacity is taken from style attribute when set vs stylesheet in IE with filters" );
|
||||
jQuery.support.opacity ?
|
||||
ok(true, "Requires the same number of tests"):
|
||||
@ -121,7 +121,7 @@ test("css() explicit and relative values", function() {
|
||||
expect(29);
|
||||
var $elem = jQuery("#nothiddendiv");
|
||||
|
||||
$elem.css({ width: 1, height: 1, paddingLeft: "1px", opacity: 1 });
|
||||
$elem.css({ "width": 1, "height": 1, "paddingLeft": "1px", "opacity": 1 });
|
||||
equal( $elem.css("width"), "1px", "Initial css set or width/height works (hash)" );
|
||||
equal( $elem.css("paddingLeft"), "1px", "Initial css set of paddingLeft works (hash)" );
|
||||
equal( $elem.css("opacity"), "1", "Initial css set of opacity works (hash)" );
|
||||
@ -129,13 +129,13 @@ test("css() explicit and relative values", function() {
|
||||
$elem.css({ width: "+=9" });
|
||||
equal( $elem.css("width"), "10px", "'+=9' on width (hash)" );
|
||||
|
||||
$elem.css({ width: "-=9" });
|
||||
$elem.css({ "width": "-=9" });
|
||||
equal( $elem.css("width"), "1px", "'-=9' on width (hash)" );
|
||||
|
||||
$elem.css({ width: "+=9px" });
|
||||
$elem.css({ "width": "+=9px" });
|
||||
equal( $elem.css("width"), "10px", "'+=9px' on width (hash)" );
|
||||
|
||||
$elem.css({ width: "-=9px" });
|
||||
$elem.css({ "width": "-=9px" });
|
||||
equal( $elem.css("width"), "1px", "'-=9px' on width (hash)" );
|
||||
|
||||
$elem.css( "width", "+=9" );
|
||||
@ -156,16 +156,16 @@ test("css() explicit and relative values", function() {
|
||||
$elem.css( "width", "+=-9px" );
|
||||
equal( $elem.css("width"), "1px", "'+=-9px' on width (params)" );
|
||||
|
||||
$elem.css({ paddingLeft: "+=4" });
|
||||
$elem.css({ "paddingLeft": "+=4" });
|
||||
equal( $elem.css("paddingLeft"), "5px", "'+=4' on paddingLeft (hash)" );
|
||||
|
||||
$elem.css({ paddingLeft: "-=4" });
|
||||
$elem.css({ "paddingLeft": "-=4" });
|
||||
equal( $elem.css("paddingLeft"), "1px", "'-=4' on paddingLeft (hash)" );
|
||||
|
||||
$elem.css({ paddingLeft: "+=4px" });
|
||||
$elem.css({ "paddingLeft": "+=4px" });
|
||||
equal( $elem.css("paddingLeft"), "5px", "'+=4px' on paddingLeft (hash)" );
|
||||
|
||||
$elem.css({ paddingLeft: "-=4px" });
|
||||
$elem.css({ "paddingLeft": "-=4px" });
|
||||
equal( $elem.css("paddingLeft"), "1px", "'-=4px' on paddingLeft (hash)" );
|
||||
|
||||
$elem.css({ "padding-left": "+=4" });
|
||||
@ -192,10 +192,10 @@ test("css() explicit and relative values", function() {
|
||||
$elem.css( "padding-left", "-=4px" );
|
||||
equal( $elem.css("paddingLeft"), "1px", "'-=4px' on padding-left (params)" );
|
||||
|
||||
$elem.css({ opacity: "-=0.5" });
|
||||
$elem.css({ "opacity": "-=0.5" });
|
||||
equal( $elem.css("opacity"), "0.5", "'-=0.5' on opacity (hash)" );
|
||||
|
||||
$elem.css({ opacity: "+=0.5" });
|
||||
$elem.css({ "opacity": "+=0.5" });
|
||||
equal( $elem.css("opacity"), "1", "'+=0.5' on opacity (hash)" );
|
||||
|
||||
$elem.css( "opacity", "-=0.5" );
|
||||
@ -365,7 +365,7 @@ test("css(Object) where values are Functions", function() {
|
||||
|
||||
var index = 0;
|
||||
|
||||
jQuery("#cssFunctionTest div").css({fontSize: function() {
|
||||
jQuery("#cssFunctionTest div").css({"fontSize": function() {
|
||||
var size = sizes[index];
|
||||
index++;
|
||||
return size;
|
||||
@ -395,7 +395,7 @@ test("css(Object) where values are Functions with incoming values", function() {
|
||||
|
||||
var index = 0;
|
||||
|
||||
jQuery("#cssFunctionTest div").css({fontSize: function() {
|
||||
jQuery("#cssFunctionTest div").css({"fontSize": function() {
|
||||
var size = sizes[index];
|
||||
index++;
|
||||
return size;
|
||||
@ -486,7 +486,7 @@ test("show(); hide()", function() {
|
||||
test("show() resolves correct default display #8099", function() {
|
||||
expect(7);
|
||||
var tt8099 = jQuery("<tt/>").appendTo("body"),
|
||||
dfn8099 = jQuery("<dfn/>", { html: "foo"}).appendTo("body");
|
||||
dfn8099 = jQuery("<dfn/>", { "html": "foo"}).appendTo("body");
|
||||
|
||||
equal( tt8099.css("display"), "none", "default display override for all tt" );
|
||||
equal( tt8099.show().css("display"), "inline", "Correctly resolves display:inline" );
|
||||
@ -621,7 +621,7 @@ test("internal ref to elem.runtimeStyle (bug #7608)", function () {
|
||||
var result = true;
|
||||
|
||||
try {
|
||||
jQuery("#foo").css( { width: "0%" } ).css("width");
|
||||
jQuery("#foo").css( { "width": "0%" } ).css("width");
|
||||
} catch (e) {
|
||||
result = false;
|
||||
}
|
||||
@ -634,8 +634,8 @@ test("marginRight computed style (bug #3333)", function() {
|
||||
|
||||
var $div = jQuery("#foo");
|
||||
$div.css({
|
||||
width: "1px",
|
||||
marginRight: 0
|
||||
"width": "1px",
|
||||
"marginRight": 0
|
||||
});
|
||||
|
||||
equal($div.css("marginRight"), "0px", "marginRight correctly calculated with a width and display block");
|
||||
@ -643,9 +643,9 @@ test("marginRight computed style (bug #3333)", function() {
|
||||
|
||||
test("jQuery.cssProps behavior, (bug #8402)", function() {
|
||||
var div = jQuery( "<div>" ).appendTo(document.body).css({
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
left: 10
|
||||
"position": "absolute",
|
||||
"top": 0,
|
||||
"left": 10
|
||||
});
|
||||
jQuery.cssProps.top = "left";
|
||||
equal( div.css("top"), "10px", "the fixed property is used when accessing the computed style");
|
||||
@ -662,16 +662,16 @@ test("widows & orphans #8936", function () {
|
||||
if ( "widows" in $p[0].style ) {
|
||||
expect(4);
|
||||
$p.css({
|
||||
widows: 0,
|
||||
orphans: 0
|
||||
"widows": 0,
|
||||
"orphans": 0
|
||||
});
|
||||
|
||||
equal( $p.css("widows") || jQuery.style( $p[0], "widows" ), 0, "widows correctly start with value 0");
|
||||
equal( $p.css("orphans") || jQuery.style( $p[0], "orphans" ), 0, "orphans correctly start with value 0");
|
||||
|
||||
$p.css({
|
||||
widows: 3,
|
||||
orphans: 3
|
||||
"widows": 3,
|
||||
"orphans": 3
|
||||
});
|
||||
|
||||
equal( $p.css("widows") || jQuery.style( $p[0], "widows" ), 3, "widows correctly set to 3");
|
||||
|
@ -3,7 +3,7 @@ module("data", { teardown: moduleTeardown });
|
||||
test("expando", function(){
|
||||
expect(1);
|
||||
|
||||
equal("expando" in jQuery, true, "jQuery is exposing the expando");
|
||||
equal(jQuery.expando !== undefined, true, "jQuery is exposing the expando");
|
||||
});
|
||||
|
||||
function dataTests (elem) {
|
||||
@ -29,14 +29,14 @@ function dataTests (elem) {
|
||||
|
||||
strictEqual( jQuery.hasData(elem), false, "jQuery.hasData agrees no data exists even when an empty data obj exists" );
|
||||
|
||||
dataObj.foo = "bar";
|
||||
dataObj["foo"] = "bar";
|
||||
equal( jQuery.data(elem, "foo"), "bar", "Data is readable by jQuery.data when set directly on a returned data object" );
|
||||
|
||||
strictEqual( jQuery.hasData(elem), true, "jQuery.hasData agrees data exists when data exists" );
|
||||
|
||||
jQuery.data(elem, "foo", "baz");
|
||||
equal( jQuery.data(elem, "foo"), "baz", "Data can be changed by jQuery.data" );
|
||||
equal( dataObj.foo, "baz", "Changes made through jQuery.data propagate to referenced data object" );
|
||||
equal( dataObj["foo"], "baz", "Changes made through jQuery.data propagate to referenced data object" );
|
||||
|
||||
jQuery.data(elem, "foo", undefined);
|
||||
equal( jQuery.data(elem, "foo"), "baz", "Data is not unset by passing undefined to jQuery.data" );
|
||||
@ -197,7 +197,7 @@ test(".data()", function() {
|
||||
|
||||
dataObj = jQuery.extend(true, {}, jQuery(obj).data());
|
||||
|
||||
deepEqual( dataObj, { foo: "baz" }, "Retrieve data object from a wrapped JS object (#7524)" );
|
||||
deepEqual( dataObj, { "foo": "baz" }, "Retrieve data object from a wrapped JS object (#7524)" );
|
||||
});
|
||||
|
||||
test(".data(String) and .data(String, Object)", function() {
|
||||
@ -428,8 +428,8 @@ test(".data(Object)", function() {
|
||||
jqobj = jQuery(obj);
|
||||
jqobj.data("test", "unset");
|
||||
jqobj.data({ "test": "in", "test2": "in2" });
|
||||
equal( jQuery.data(obj).test, "in", "Verify setting an object on an object extends the data object" );
|
||||
equal( obj.test2, undefined, "Verify setting an object on an object does not extend the object" );
|
||||
equal( jQuery.data(obj)["test"], "in", "Verify setting an object on an object extends the data object" );
|
||||
equal( obj["test2"], undefined, "Verify setting an object on an object does not extend the object" );
|
||||
|
||||
// manually clean up detached elements
|
||||
div.remove();
|
||||
@ -463,7 +463,7 @@ test("jQuery.removeData", function() {
|
||||
|
||||
jQuery.data(div, {
|
||||
"test3 test4": "testing",
|
||||
test3: "testing"
|
||||
"test3": "testing"
|
||||
});
|
||||
jQuery.removeData( div, "test3 test4" );
|
||||
ok( !jQuery.data(div, "test3 test4"), "Multiple delete with spaces deleted key with exact name" );
|
||||
@ -505,7 +505,7 @@ if (window.JSON && window.JSON.stringify) {
|
||||
test("JSON serialization (#8108)", function () {
|
||||
expect(1);
|
||||
|
||||
var obj = { foo: "bar" };
|
||||
var obj = { "foo": "bar" };
|
||||
jQuery.data(obj, "hidden", true);
|
||||
|
||||
equal( JSON.stringify(obj), "{\"foo\":\"bar\"}", "Expando is hidden from JSON.stringify" );
|
||||
@ -518,12 +518,12 @@ test("jQuery.data should follow html5 specification regarding camel casing", fun
|
||||
var div = jQuery("<div id='myObject' data-w-t-f='ftw' data-big-a-little-a='bouncing-b' data-foo='a' data-foo-bar='b' data-foo-bar-baz='c'></div>")
|
||||
.prependTo("body");
|
||||
|
||||
equal( div.data().wTF, "ftw", "Verify single letter data-* key" );
|
||||
equal( div.data().bigALittleA, "bouncing-b", "Verify single letter mixed data-* key" );
|
||||
equal( div.data()["wTF"], "ftw", "Verify single letter data-* key" );
|
||||
equal( div.data()["bigALittleA"], "bouncing-b", "Verify single letter mixed data-* key" );
|
||||
|
||||
equal( div.data().foo, "a", "Verify single word data-* key" );
|
||||
equal( div.data().fooBar, "b", "Verify multiple word data-* key" );
|
||||
equal( div.data().fooBarBaz, "c", "Verify multiple word data-* key" );
|
||||
equal( div.data()["foo"], "a", "Verify single word data-* key" );
|
||||
equal( div.data()["fooBar"], "b", "Verify multiple word data-* key" );
|
||||
equal( div.data()["fooBarBaz"], "c", "Verify multiple word data-* key" );
|
||||
|
||||
equal( div.data("foo"), "a", "Verify single word data-* key" );
|
||||
equal( div.data("fooBar"), "b", "Verify multiple word data-* key" );
|
||||
@ -627,8 +627,8 @@ test("Triggering the removeData should not throw exceptions. (#10080)", function
|
||||
test( "Only check element attributes once when calling .data() - #8909", function() {
|
||||
expect( 2 );
|
||||
var testing = {
|
||||
test: "testing",
|
||||
test2: "testing"
|
||||
"test": "testing",
|
||||
"test2": "testing"
|
||||
},
|
||||
element = jQuery( "<div data-test='testing'>" ),
|
||||
node = element[ 0 ];
|
||||
|
@ -39,7 +39,8 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
|
||||
strictEqual( value , "done" , "Passed function executed" );
|
||||
});
|
||||
|
||||
jQuery.each( "resolve reject".split( " " ), function( _, change ) {
|
||||
jQuery.expandedEach = jQuery.each;
|
||||
jQuery.expandedEach( "resolve reject".split( " " ), function( _, change ) {
|
||||
createDeferred( function( defer ) {
|
||||
strictEqual( defer.state(), "pending", "pending after creation" );
|
||||
var checked = 0;
|
||||
@ -60,12 +61,12 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
|
||||
|
||||
test( "jQuery.Deferred - chainability", function() {
|
||||
|
||||
var methods = "resolve reject notify resolveWith rejectWith notifyWith done fail progress always".split( " " ),
|
||||
defer = jQuery.Deferred();
|
||||
var defer = jQuery.Deferred();
|
||||
|
||||
expect( methods.length );
|
||||
expect( 10 );
|
||||
|
||||
jQuery.each( methods, function( _, method ) {
|
||||
jQuery.expandedEach = jQuery.each;
|
||||
jQuery.expandedEach( "resolve reject notify resolveWith rejectWith notifyWith done fail progress always".split( " " ), function( _, method ) {
|
||||
var object = { m: defer[ method ] };
|
||||
strictEqual( object.m(), object, method + " is chainable" );
|
||||
});
|
||||
|
@ -38,11 +38,11 @@ var testWidth = function( val ) {
|
||||
$div.css("border", "2px solid #fff");
|
||||
equal($div.width(), 0, "Test border specified with pixels");
|
||||
|
||||
$div.css({ display: "", border: "", padding: "" });
|
||||
$div.css({ "display": "", "border": "", "padding": "" });
|
||||
|
||||
jQuery("#nothiddendivchild").css({ width: 20, padding: "3px", border: "2px solid #fff" });
|
||||
jQuery("#nothiddendivchild").css({ "width": 20, "padding": "3px", "border": "2px solid #fff" });
|
||||
equal(jQuery("#nothiddendivchild").width(), 20, "Test child width with border and padding");
|
||||
jQuery("#nothiddendiv, #nothiddendivchild").css({ border: "", padding: "", width: "" });
|
||||
jQuery("#nothiddendiv, #nothiddendivchild").css({ "border": "", "padding": "", "width": "" });
|
||||
|
||||
var blah = jQuery("blah");
|
||||
equal( blah.width( val(10) ), blah, "Make sure that setting a width on an empty set returns the set." );
|
||||
@ -89,11 +89,11 @@ var testHeight = function( val ) {
|
||||
$div.css("border", "2px solid #fff");
|
||||
equal($div.height(), 0, "Test border specified with pixels");
|
||||
|
||||
$div.css({ display: "", border: "", padding: "", height: "1px" });
|
||||
$div.css({ "display": "", "border": "", "padding": "", "height": "1px" });
|
||||
|
||||
jQuery("#nothiddendivchild").css({ height: 20, padding: "3px", border: "2px solid #fff" });
|
||||
jQuery("#nothiddendivchild").css({ "height": 20, "padding": "3px", "border": "2px solid #fff" });
|
||||
equal(jQuery("#nothiddendivchild").height(), 20, "Test child height with border and padding");
|
||||
jQuery("#nothiddendiv, #nothiddendivchild").css({ border: "", padding: "", height: "" });
|
||||
jQuery("#nothiddendiv, #nothiddendivchild").css({ "border": "", "padding": "", "height": "" });
|
||||
|
||||
var blah = jQuery("blah");
|
||||
equal( blah.height( val(10) ), blah, "Make sure that setting a height on an empty set returns the set." );
|
||||
@ -136,9 +136,9 @@ test("innerWidth()", function() {
|
||||
var $div = jQuery("#nothiddendiv");
|
||||
// set styles
|
||||
$div.css({
|
||||
margin: 10,
|
||||
border: "2px solid #fff",
|
||||
width: 30
|
||||
"margin": 10,
|
||||
"border": "2px solid #fff",
|
||||
"width": 30
|
||||
});
|
||||
|
||||
equal($div.innerWidth(), 30, "Test with margin and border");
|
||||
@ -148,7 +148,7 @@ test("innerWidth()", function() {
|
||||
equal($div.innerWidth(), 70, "Test hidden div");
|
||||
|
||||
// reset styles
|
||||
$div.css({ display: "", border: "", padding: "", width: "", height: "" });
|
||||
$div.css({ "display": "", "border": "", "padding": "", "width": "", "height": "" });
|
||||
|
||||
var div = jQuery( "<div>" );
|
||||
|
||||
@ -171,9 +171,9 @@ test("innerHeight()", function() {
|
||||
var $div = jQuery("#nothiddendiv");
|
||||
// set styles
|
||||
$div.css({
|
||||
margin: 10,
|
||||
border: "2px solid #fff",
|
||||
height: 30
|
||||
"margin": 10,
|
||||
"border": "2px solid #fff",
|
||||
"height": 30
|
||||
});
|
||||
|
||||
equal($div.innerHeight(), 30, "Test with margin and border");
|
||||
@ -183,7 +183,7 @@ test("innerHeight()", function() {
|
||||
equal($div.innerHeight(), 70, "Test hidden div");
|
||||
|
||||
// reset styles
|
||||
$div.css({ display: "", border: "", padding: "", width: "", height: "" });
|
||||
$div.css({ "display": "", "border": "", "padding": "", "width": "", "height": "" });
|
||||
|
||||
var div = jQuery( "<div>" );
|
||||
|
||||
@ -221,7 +221,7 @@ test("outerWidth()", function() {
|
||||
equal($div.outerWidth(true), 94, "Test hidden div with padding, border and margin with margin option");
|
||||
|
||||
// reset styles
|
||||
$div.css({ position: "", display: "", border: "", padding: "", width: "", height: "" });
|
||||
$div.css({ "position": "", "display": "", "border": "", "padding": "", "width": "", "height": "" });
|
||||
|
||||
var div = jQuery( "<div>" );
|
||||
|
||||
@ -236,7 +236,7 @@ test("child of a hidden elem (or unconnected node) has accurate inner/outer/Widt
|
||||
expect(16);
|
||||
|
||||
// setup html
|
||||
var $divNormal = jQuery("<div>").css({ width: "100px", height: "100px", border: "10px solid white", padding: "2px", margin: "3px" }),
|
||||
var $divNormal = jQuery("<div>").css({ "width": "100px", "height": "100px", "border": "10px solid white", "padding": "2px", "margin": "3px" }),
|
||||
$divChild = $divNormal.clone(),
|
||||
$divUnconnected = $divNormal.clone(),
|
||||
$divHiddenParent = jQuery("<div>").css( "display", "none" ).append( $divChild ).appendTo("body");
|
||||
@ -294,7 +294,7 @@ test("getting dimensions shouldnt modify runtimeStyle see #9233", function() {
|
||||
|
||||
test("outerWidth(true) returning % instead of px in Webkit, see #10639", function() {
|
||||
var container = jQuery( "<div/>" ).width(400).appendTo( "#qunit-fixture" ),
|
||||
el = jQuery( "<div/>" ).css({ width: "50%", marginRight: "50%" }).appendTo( container );
|
||||
el = jQuery( "<div/>" ).css({ "width": "50%", "marginRight": "50%" }).appendTo( container );
|
||||
|
||||
equal( el.outerWidth(true), 400, "outerWidth(true) and css('margin') returning % instead of px in Webkit, see #10639" );
|
||||
});
|
||||
@ -305,7 +305,7 @@ test( "getting dimensions of zero width/height table elements shouldn't alter di
|
||||
var table = jQuery("<table><tbody><tr><td></td><td>a</td></tr><tr><td></td><td>a</td></tr></tbody></table>").appendTo("#qunit-fixture"),
|
||||
elem = table.find("tr:eq(0) td:eq(0)");
|
||||
|
||||
table.find("td").css({ margin: 0, padding: 0 });
|
||||
table.find("td").css({ "margin": 0, "padding": 0 });
|
||||
equal( elem.width(), elem.width(), "width() doesn't alter dimension values" );
|
||||
});
|
||||
|
||||
@ -313,7 +313,7 @@ test("box-sizing:border-box child of a hidden elem (or unconnected node) has acc
|
||||
expect(16);
|
||||
|
||||
// setup html
|
||||
var $divNormal = jQuery("<div>").css({ boxSizing: "border-box", width: "100px", height: "100px", border: "10px solid white", padding: "2px", margin: "3px" }),
|
||||
var $divNormal = jQuery("<div>").css({ "boxSizing": "border-box", "width": "100px", "height": "100px", "border": "10px solid white", "padding": "2px", "margin": "3px" }),
|
||||
$divChild = $divNormal.clone(),
|
||||
$divUnconnected = $divNormal.clone(),
|
||||
$divHiddenParent = jQuery("<div>").css( "display", "none" ).append( $divChild ).appendTo("body");
|
||||
@ -373,7 +373,7 @@ test("outerHeight()", function() {
|
||||
equal($div.outerHeight(true), 94, "Test hidden div with padding, border and margin with margin option");
|
||||
|
||||
// reset styles
|
||||
$div.css({ display: "", border: "", padding: "", width: "", height: "" });
|
||||
$div.css({ "display": "", "border": "", "padding": "", "width": "", "height": "" });
|
||||
|
||||
var div = jQuery( "<div>" );
|
||||
|
||||
|
60
test/unit/effects.js
vendored
60
test/unit/effects.js
vendored
@ -199,7 +199,7 @@ test("animate negative height", function() {
|
||||
test("animate negative margin", function() {
|
||||
expect(1);
|
||||
stop();
|
||||
jQuery("#foo").animate({ marginTop: -100 }, 100, function() {
|
||||
jQuery("#foo").animate({ "marginTop": -100 }, 100, function() {
|
||||
equal( jQuery(this).css("marginTop"), "-100px", "Verify margin." );
|
||||
start();
|
||||
});
|
||||
@ -217,7 +217,7 @@ test("animate negative margin with px", function() {
|
||||
test("animate negative padding", function() {
|
||||
expect(1);
|
||||
stop();
|
||||
jQuery("#foo").animate({ paddingBottom: -100 }, 100, function() {
|
||||
jQuery("#foo").animate({ "paddingBottom": -100 }, 100, function() {
|
||||
equal( jQuery(this).css("paddingBottom"), "0px", "Verify paddingBottom." );
|
||||
start();
|
||||
});
|
||||
@ -559,7 +559,7 @@ test("stop()", function() {
|
||||
var w = 0;
|
||||
|
||||
$foo.hide().css( "width", 200 )
|
||||
.animate( { width: "show" }, 1000 );
|
||||
.animate( { "width": "show" }, 1000 );
|
||||
|
||||
setTimeout(function() {
|
||||
var nw = $foo.css("width");
|
||||
@ -598,9 +598,9 @@ test("stop() - several in queue", function() {
|
||||
var w = 0;
|
||||
$foo.hide().css( "width", 200 ).css("width");
|
||||
|
||||
$foo.animate({ width: "show" }, 1000);
|
||||
$foo.animate({ width: "hide" }, 1000);
|
||||
$foo.animate({ width: "show" }, 1000);
|
||||
$foo.animate({ "width": "show" }, 1000);
|
||||
$foo.animate({ "width": "hide" }, 1000);
|
||||
$foo.animate({ "width": "show" }, 1000);
|
||||
setTimeout(function(){
|
||||
equal( $foo.queue().length, 3, "All 3 still in the queue" );
|
||||
var nw = $foo.css("width");
|
||||
@ -623,9 +623,9 @@ test("stop(clearQueue)", function() {
|
||||
var w = 0;
|
||||
$foo.hide().css( "width", 200 ).css("width");
|
||||
|
||||
$foo.animate({ width: "show" }, 1000);
|
||||
$foo.animate({ width: "hide" }, 1000);
|
||||
$foo.animate({ width: "show" }, 1000);
|
||||
$foo.animate({ "width": "show" }, 1000);
|
||||
$foo.animate({ "width": "hide" }, 1000);
|
||||
$foo.animate({ "width": "show" }, 1000);
|
||||
setTimeout(function(){
|
||||
var nw = $foo.css("width");
|
||||
ok( parseFloat( nw ) != w, "An animation occurred " + nw + " " + w + "px");
|
||||
@ -999,6 +999,7 @@ jQuery.fn.saveState = function( hiddenOverflow ) {
|
||||
});
|
||||
};
|
||||
|
||||
/** @expose */
|
||||
jQuery.checkState = function() {
|
||||
var self = this;
|
||||
jQuery.each(this.save, function( c, v ) {
|
||||
@ -1097,7 +1098,8 @@ test("jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function ()
|
||||
});
|
||||
});
|
||||
|
||||
jQuery.each({
|
||||
jQuery.expandedEach = jQuery.each;
|
||||
jQuery.expandedEach({
|
||||
"slideToggle": function( $elem ) {
|
||||
return parseFloat( $elem.css("height") );
|
||||
},
|
||||
@ -1165,17 +1167,17 @@ test("animate with per-property easing", function(){
|
||||
c: 100
|
||||
};
|
||||
|
||||
jQuery.easing._test1 = function(p) {
|
||||
jQuery.easing["_test1"] = function(p) {
|
||||
_test1_called = true;
|
||||
return p;
|
||||
};
|
||||
|
||||
jQuery.easing._test2 = function(p) {
|
||||
jQuery.easing["_test2"] = function(p) {
|
||||
_test2_called = true;
|
||||
return p;
|
||||
};
|
||||
|
||||
jQuery.easing._default_test = function(p) {
|
||||
jQuery.easing["_default_test"] = function(p) {
|
||||
_default_test_called = true;
|
||||
return p;
|
||||
};
|
||||
@ -1198,8 +1200,8 @@ test("animate with CSS shorthand properties", function(){
|
||||
|
||||
var _default_count = 0,
|
||||
_special_count = 0,
|
||||
propsBasic = { padding: "10 20 30" },
|
||||
propsSpecial = { padding: [ "1 2 3", "_special" ] };
|
||||
propsBasic = { "padding": "10 20 30" },
|
||||
propsSpecial = { "padding": [ "1 2 3", "_special" ] };
|
||||
|
||||
jQuery.easing._default = function(p) {
|
||||
if ( p >= 1 ) {
|
||||
@ -1345,24 +1347,24 @@ test("animate will scale margin properties individually", function() {
|
||||
stop();
|
||||
|
||||
var foo = jQuery( "#foo" ).css({
|
||||
margin: 0,
|
||||
marginLeft: 100
|
||||
"margin": 0,
|
||||
"marginLeft": 100
|
||||
});
|
||||
|
||||
ok( foo.css( "marginLeft" ) !== foo.css( "marginRight" ), "Sanity Check" );
|
||||
|
||||
foo.animate({
|
||||
margin: 200
|
||||
"margin": 200
|
||||
}).stop();
|
||||
|
||||
ok( foo.css( "marginLeft") !== foo.css( "marginRight" ), "The margin properties are different");
|
||||
|
||||
// clean up for next test
|
||||
foo.css({
|
||||
marginLeft: "",
|
||||
marginRight: "",
|
||||
marginTop: "",
|
||||
marginBottom: ""
|
||||
"marginLeft": '',
|
||||
"marginRight": '',
|
||||
"marginTop": '',
|
||||
"marginBottom": ''
|
||||
});
|
||||
start();
|
||||
});
|
||||
@ -1379,17 +1381,17 @@ test("Do not append px to 'fill-opacity' #9548", 1, function() {
|
||||
// Start 1.8 Animation tests
|
||||
asyncTest( "jQuery.Animation( object, props, opts )", 4, function() {
|
||||
var testObject = {
|
||||
foo: 0,
|
||||
bar: 1,
|
||||
width: 100
|
||||
"foo": 0,
|
||||
"bar": 1,
|
||||
"width": 100
|
||||
},
|
||||
testDest = {
|
||||
foo: 1,
|
||||
bar: 0,
|
||||
width: 200
|
||||
"foo": 1,
|
||||
"bar": 0,
|
||||
"width": 200
|
||||
};
|
||||
|
||||
var animation = jQuery.Animation( testObject, testDest, { duration: 1 });
|
||||
var animation = jQuery.Animation( testObject, testDest, { "duration": 1 });
|
||||
animation.done(function() {
|
||||
for ( var prop in testDest ) {
|
||||
equal( testObject[ prop ], testDest[ prop ], "Animated: " + prop );
|
||||
|
@ -64,9 +64,9 @@ test("bind(), with data", function() {
|
||||
expect(4);
|
||||
var handler = function(event) {
|
||||
ok( event.data, "bind() with data, check passed data exists" );
|
||||
equal( event.data.foo, "bar", "bind() with data, Check value of passed data" );
|
||||
equal( event.data["foo"], "bar", "bind() with data, Check value of passed data" );
|
||||
};
|
||||
jQuery("#firstp").bind("click", {foo: "bar"}, handler).click().unbind("click", handler);
|
||||
jQuery("#firstp").bind("click", {"foo": "bar"}, handler).click().unbind("click", handler);
|
||||
|
||||
ok( !jQuery._data(jQuery("#firstp")[0], "events"), "Event handler unbound when using data." );
|
||||
|
||||
@ -81,9 +81,9 @@ test("click(), with data", function() {
|
||||
expect(3);
|
||||
var handler = function(event) {
|
||||
ok( event.data, "bind() with data, check passed data exists" );
|
||||
equal( event.data.foo, "bar", "bind() with data, Check value of passed data" );
|
||||
equal( event.data["foo"], "bar", "bind() with data, Check value of passed data" );
|
||||
};
|
||||
jQuery("#firstp").click({foo: "bar"}, handler).click().unbind("click", handler);
|
||||
jQuery("#firstp").click({"foo": "bar"}, handler).click().unbind("click", handler);
|
||||
|
||||
ok( !jQuery._data(jQuery("#firstp")[0], "events"), "Event handler unbound when using data." );
|
||||
});
|
||||
@ -185,7 +185,7 @@ test("bind(), namespace with special add", function() {
|
||||
|
||||
var i = 0;
|
||||
|
||||
jQuery.event.special.test = {
|
||||
jQuery.event.special["test"] = {
|
||||
_default: function(e, data) {
|
||||
equal( this, document, "Make sure we're at the top of the chain." );
|
||||
equal( e.type, "test", "And that we're still dealing with a test event." );
|
||||
@ -208,14 +208,14 @@ test("bind(), namespace with special add", function() {
|
||||
}
|
||||
};
|
||||
|
||||
div.bind("test.a", {x: 1}, function(e) {
|
||||
div.bind("test.a", {"x": 1}, function(e) {
|
||||
ok( !!e.xyz, "Make sure that the data is getting passed through." );
|
||||
equal( e.data.x, 1, "Make sure data is attached properly." );
|
||||
equal( e.data["x"], 1, "Make sure data is attached properly." );
|
||||
});
|
||||
|
||||
div.bind("test.b", {x: 2}, function(e) {
|
||||
div.bind("test.b", {"x": 2}, function(e) {
|
||||
ok( !!e.xyz, "Make sure that the data is getting passed through." );
|
||||
equal( e.data.x, 2, "Make sure data is attached properly." );
|
||||
equal( e.data["x"], 2, "Make sure data is attached properly." );
|
||||
});
|
||||
|
||||
// Should trigger 5
|
||||
@ -237,7 +237,7 @@ test("bind(), namespace with special add", function() {
|
||||
// Should trigger 2
|
||||
div.appendTo("#qunit-fixture").remove();
|
||||
|
||||
delete jQuery.event.special.test;
|
||||
delete jQuery.event.special["test"];
|
||||
});
|
||||
|
||||
test("bind(), no data", function() {
|
||||
@ -279,13 +279,13 @@ test("bind/one/unbind(Object)", function(){
|
||||
var $elem = jQuery("#firstp")
|
||||
// Regular bind
|
||||
.bind({
|
||||
click:handler,
|
||||
mouseover:handler
|
||||
"click":handler,
|
||||
"mouseover":handler
|
||||
})
|
||||
// Bind with data
|
||||
.one({
|
||||
click:handlerWithData,
|
||||
mouseover:handlerWithData
|
||||
"click":handlerWithData,
|
||||
"mouseover":handlerWithData
|
||||
}, 2 );
|
||||
|
||||
trigger();
|
||||
@ -298,8 +298,8 @@ test("bind/one/unbind(Object)", function(){
|
||||
equal( mouseoverCounter, 4, "bind(Object)" );
|
||||
|
||||
jQuery("#firstp").unbind({
|
||||
click:handler,
|
||||
mouseover:handler
|
||||
"click":handler,
|
||||
"mouseover":handler
|
||||
});
|
||||
|
||||
trigger();
|
||||
@ -314,10 +314,10 @@ test("live/die(Object), delegate/undelegate(String, Object)", function() {
|
||||
$p = jQuery("#firstp"), $a = $p.find("a:first");
|
||||
|
||||
var events = {
|
||||
click: function( event ) {
|
||||
"click": function( event ) {
|
||||
clickCounter += ( event.data || 1 );
|
||||
},
|
||||
mouseover: function( event ) {
|
||||
"mouseover": function( event ) {
|
||||
mouseoverCounter += ( event.data || 1 );
|
||||
}
|
||||
};
|
||||
@ -397,7 +397,7 @@ test("bind/delegate bubbling, isDefaultPrevented", function() {
|
||||
$main.delegate("#foo", "click", function(e) {
|
||||
var orig = e.originalEvent;
|
||||
|
||||
if ( typeof(orig.defaultPrevented) === "boolean" || typeof(orig.returnValue) === "boolean" || orig.getPreventDefault ) {
|
||||
if ( typeof(orig.defaultPrevented) === "boolean" || typeof(orig.returnValue) === "boolean" || orig["getPreventDefault"] ) {
|
||||
equal( e.isDefaultPrevented(), true, "isDefaultPrevented true passed to bubbled event" );
|
||||
|
||||
} else {
|
||||
@ -682,19 +682,19 @@ test("bind()/trigger()/unbind() on plain object", function() {
|
||||
jQuery(obj).unbind("test");
|
||||
|
||||
jQuery(obj).bind({
|
||||
test: function() {
|
||||
"test": function() {
|
||||
ok( true, "Custom event run." );
|
||||
},
|
||||
submit: function() {
|
||||
"submit": function() {
|
||||
ok( true, "Custom submit event run." );
|
||||
}
|
||||
});
|
||||
|
||||
var events = jQuery._data(obj, "events");
|
||||
ok( events, "Object has events bound." );
|
||||
equal( obj.events, undefined, "Events object on plain objects is not events" );
|
||||
equal( obj.test, undefined, "Make sure that test event is not on the plain object." );
|
||||
equal( obj.handle, undefined, "Make sure that the event handler is not on the plain object." );
|
||||
equal( obj["events"], undefined, "Events object on plain objects is not events" );
|
||||
equal( obj["test"], undefined, "Make sure that test event is not on the plain object." );
|
||||
equal( obj["handle"], undefined, "Make sure that the event handler is not on the plain object." );
|
||||
|
||||
// Should trigger 1
|
||||
jQuery(obj).trigger("test");
|
||||
@ -711,7 +711,7 @@ test("bind()/trigger()/unbind() on plain object", function() {
|
||||
|
||||
equal( obj && obj[ jQuery.expando ] &&
|
||||
obj[ jQuery.expando ][ jQuery.expando ] &&
|
||||
obj[ jQuery.expando ][ jQuery.expando ].events, undefined, "Make sure events object is removed" );
|
||||
obj[ jQuery.expando ][ jQuery.expando ]["events"], undefined, "Make sure events object is removed" );
|
||||
});
|
||||
|
||||
test("unbind(type)", function() {
|
||||
@ -1182,7 +1182,7 @@ test("trigger(eventObject, [data], [fn])", function() {
|
||||
$child.trigger(event);
|
||||
|
||||
// test with a literal object
|
||||
$child.trigger({type: "foo", secret: "boo!"});
|
||||
$child.trigger({"type": "foo", "secret": "boo!"});
|
||||
|
||||
$parent.unbind();
|
||||
|
||||
@ -1642,9 +1642,9 @@ test(".live()/.die()", function() {
|
||||
// Test binding with different this object, event data, and trigger data
|
||||
jQuery("#foo").live("click", true, jQuery.proxy(function(e, data){
|
||||
equal( e.data, true, "live with with different this object, event data, and trigger data" );
|
||||
equal( this.foo, "bar", "live with with different this object, event data, and trigger data" );
|
||||
equal( this["foo"], "bar", "live with with different this object, event data, and trigger data" );
|
||||
equal( data, true, "live with with different this object, event data, and trigger data");
|
||||
}, { foo: "bar" }));
|
||||
}, { "foo": "bar" }));
|
||||
jQuery("#foo").trigger("click", true).die("click");
|
||||
|
||||
// Verify that return false prevents default action
|
||||
@ -2010,7 +2010,7 @@ test("live with submit", function() {
|
||||
test("live with special events", function() {
|
||||
expect(13);
|
||||
|
||||
jQuery.event.special.foo = {
|
||||
jQuery.event.special["foo"] = {
|
||||
setup: function( data, namespaces, handler ) {
|
||||
ok( true, "Setup run." );
|
||||
},
|
||||
@ -2053,7 +2053,7 @@ test("live with special events", function() {
|
||||
// Run: remove, teardown
|
||||
jQuery("#liveSpan1").die("foo");
|
||||
|
||||
delete jQuery.event.special.foo;
|
||||
delete jQuery.event.special["foo"];
|
||||
});
|
||||
|
||||
test(".delegate()/.undelegate()", function() {
|
||||
@ -2169,7 +2169,7 @@ test(".delegate()/.undelegate()", function() {
|
||||
jQuery("#body").undelegate("#foo", "click");
|
||||
|
||||
// Test binding with different this object
|
||||
jQuery("#body").delegate("#foo", "click", jQuery.proxy(function(e){ equal( this.foo, "bar", "delegate with event scope" ); }, { foo: "bar" }));
|
||||
jQuery("#body").delegate("#foo", "click", jQuery.proxy(function(e){ equal( this["foo"], "bar", "delegate with event scope" ); }, { "foo": "bar" }));
|
||||
jQuery("#foo").trigger("click");
|
||||
jQuery("#body").undelegate("#foo", "click");
|
||||
|
||||
@ -2178,7 +2178,7 @@ test(".delegate()/.undelegate()", function() {
|
||||
equal( e.data, true, "delegate with with different this object, event data, and trigger data" );
|
||||
equal( this.foo, "bar", "delegate with with different this object, event data, and trigger data" );
|
||||
equal( data, true, "delegate with with different this object, event data, and trigger data");
|
||||
}, { foo: "bar" }));
|
||||
}, { "foo": "bar" }));
|
||||
jQuery("#foo").trigger("click", true);
|
||||
jQuery("#body").undelegate("#foo", "click");
|
||||
|
||||
@ -2703,7 +2703,7 @@ test(".on and .off", function() {
|
||||
|
||||
// We should have removed all the event handlers ... kinda hacky way to check this
|
||||
var data = jQuery.data[ jQuery( "#onandoff" )[0].expando ] || {};
|
||||
equal( data.events, undefined, "no events left" );
|
||||
equal( data["events"], undefined, "no events left" );
|
||||
|
||||
$onandoff.remove();
|
||||
});
|
||||
@ -2711,7 +2711,7 @@ test(".on and .off", function() {
|
||||
test("special bind/delegate name mapping", function() {
|
||||
expect( 7 );
|
||||
|
||||
jQuery.event.special.slap = {
|
||||
jQuery.event.special["slap"] = {
|
||||
bindType: "click",
|
||||
delegateType: "swing",
|
||||
handle: function( event ) {
|
||||
@ -2742,9 +2742,9 @@ test("special bind/delegate name mapping", function() {
|
||||
.trigger( "swing" )
|
||||
.end()
|
||||
.remove();
|
||||
delete jQuery.event.special.slap;
|
||||
delete jQuery.event.special["slap"];
|
||||
|
||||
jQuery.event.special.gutfeeling = {
|
||||
jQuery.event.special["gutfeeling"] = {
|
||||
bindType: "click",
|
||||
delegateType: "click",
|
||||
handle: function( event ) {
|
||||
@ -2776,7 +2776,7 @@ test("special bind/delegate name mapping", function() {
|
||||
.trigger( "gutfeeling" ) // This one should not
|
||||
.remove();
|
||||
|
||||
delete jQuery.event.special.gutfeeling;
|
||||
delete jQuery.event.special["gutfeeling"];
|
||||
});
|
||||
|
||||
test(".on and .off, selective mixed removal (#10705)", function() {
|
||||
@ -2821,7 +2821,7 @@ test(".on( event-map, null-selector, data ) #11130", function() {
|
||||
test("clone() delegated events (#11076)", function() {
|
||||
expect(3);
|
||||
|
||||
var counter = { center: 0, fold: 0, centerfold: 0 },
|
||||
var counter = { "center": 0, "fold": 0, "centerfold": 0 },
|
||||
clicked = function( event ) {
|
||||
counter[ jQuery(this).text().replace(/\s+/, "") ]++;
|
||||
},
|
||||
@ -2833,9 +2833,9 @@ test("clone() delegated events (#11076)", function() {
|
||||
clone = table.clone( true );
|
||||
|
||||
clone.find("td").click();
|
||||
equal( counter.center, 1, "first child" );
|
||||
equal( counter.fold, 1, "last child" );
|
||||
equal( counter.centerfold, 2, "all children" );
|
||||
equal( counter["center"], 1, "first child" );
|
||||
equal( counter["fold"], 1, "last child" );
|
||||
equal( counter["centerfold"], 2, "all children" );
|
||||
|
||||
table.remove();
|
||||
clone.remove();
|
||||
@ -2943,9 +2943,9 @@ if ( hasPHP ) {
|
||||
deepEqual(order, ["a", "b", "d", "e", "c", "f"], "Bound DOM ready handlers should execute in bind-order, but those bound with jQuery(document).bind( 'ready', fn ) will always execute last");
|
||||
|
||||
// Ensure handler argument is correct.
|
||||
equal(args.a, jQuery, "Argument passed to fn in jQuery( fn ) should be jQuery");
|
||||
equal(args.b, jQuery, "Argument passed to fn in jQuery(document).ready( fn ) should be jQuery");
|
||||
ok(args.c instanceof jQuery.Event, "Argument passed to fn in jQuery(document).bind( 'ready', fn ) should be an event object");
|
||||
equal(args["a"], jQuery, "Argument passed to fn in jQuery( fn ) should be jQuery");
|
||||
equal(args["b"], jQuery, "Argument passed to fn in jQuery(document).ready( fn ) should be jQuery");
|
||||
ok(args["c"] instanceof jQuery.Event, "Argument passed to fn in jQuery(document).bind( 'ready', fn ) should be an event object");
|
||||
|
||||
order = [];
|
||||
|
||||
@ -2953,11 +2953,11 @@ if ( hasPHP ) {
|
||||
// in every possible way. These event handlers should execute immediately.
|
||||
jQuery(makeHandler("g"));
|
||||
equal(order.pop(), "g", "Event handler should execute immediately");
|
||||
equal(args.g, jQuery, "Argument passed to fn in jQuery( fn ) should be jQuery");
|
||||
equal(args["g"], jQuery, "Argument passed to fn in jQuery( fn ) should be jQuery");
|
||||
|
||||
jQuery(document).ready(makeHandler("h"));
|
||||
equal(order.pop(), "h", "Event handler should execute immediately");
|
||||
equal(args.h, jQuery, "Argument passed to fn in jQuery(document).ready( fn ) should be jQuery");
|
||||
equal(args["h"], jQuery, "Argument passed to fn in jQuery(document).ready( fn ) should be jQuery");
|
||||
|
||||
jQuery(document).bind("ready.readytest", makeHandler("never"));
|
||||
equal(order.length, 0, "Event handler should never execute since DOM ready has already passed");
|
||||
|
@ -3,13 +3,13 @@ module("manipulation", { teardown: moduleTeardown });
|
||||
// Ensure that an extended Array prototype doesn't break jQuery
|
||||
Array.prototype.arrayProtoFn = function(arg) { throw("arrayProtoFn should not be called"); };
|
||||
|
||||
var bareObj = function(value) { return value; };
|
||||
var functionReturningObj = function(value) { return (function() { return value; }); };
|
||||
var manipulationBareObj = function(value) { return value; };
|
||||
var manipulationFunctionReturningObj = function(value) { return (function() { return value; }); };
|
||||
|
||||
|
||||
/*
|
||||
======== local reference =======
|
||||
bareObj and functionReturningObj can be used to test passing functions to setters
|
||||
manipulationBareObj and manipulationFunctionReturningObj can be used to test passing functions to setters
|
||||
See testVal below for an example
|
||||
|
||||
bareObj( value );
|
||||
@ -62,11 +62,11 @@ var testText = function(valueObj) {
|
||||
};
|
||||
|
||||
test("text(String)", function() {
|
||||
testText(bareObj);
|
||||
testText(manipulationBareObj);
|
||||
});
|
||||
|
||||
test("text(Function)", function() {
|
||||
testText(functionReturningObj);
|
||||
testText(manipulationFunctionReturningObj);
|
||||
});
|
||||
|
||||
test("text(Function) with incoming value", function() {
|
||||
@ -161,11 +161,11 @@ var testWrap = function(val) {
|
||||
};
|
||||
|
||||
test("wrap(String|Element)", function() {
|
||||
testWrap(bareObj);
|
||||
testWrap(manipulationBareObj);
|
||||
});
|
||||
|
||||
test("wrap(Function)", function() {
|
||||
testWrap(functionReturningObj);
|
||||
testWrap(manipulationFunctionReturningObj);
|
||||
});
|
||||
|
||||
test("wrap(Function) with index (#10177)", function() {
|
||||
@ -217,7 +217,7 @@ var testWrapAll = function(val) {
|
||||
};
|
||||
|
||||
test("wrapAll(String|Element)", function() {
|
||||
testWrapAll(bareObj);
|
||||
testWrapAll(manipulationBareObj);
|
||||
});
|
||||
|
||||
var testWrapInner = function(val) {
|
||||
@ -249,11 +249,11 @@ var testWrapInner = function(val) {
|
||||
};
|
||||
|
||||
test("wrapInner(String|Element)", function() {
|
||||
testWrapInner(bareObj);
|
||||
testWrapInner(manipulationBareObj);
|
||||
});
|
||||
|
||||
test("wrapInner(Function)", function() {
|
||||
testWrapInner(functionReturningObj);
|
||||
testWrapInner(manipulationFunctionReturningObj);
|
||||
});
|
||||
|
||||
test("unwrap()", function() {
|
||||
@ -462,11 +462,11 @@ var testAppend = function(valueObj) {
|
||||
};
|
||||
|
||||
test("append(String|Element|Array<Element>|jQuery)", function() {
|
||||
testAppend(bareObj);
|
||||
testAppend(manipulationBareObj);
|
||||
});
|
||||
|
||||
test("append(Function)", function() {
|
||||
testAppend(functionReturningObj);
|
||||
testAppend(manipulationFunctionReturningObj);
|
||||
});
|
||||
|
||||
test("append(Function) with incoming value", function() {
|
||||
@ -531,7 +531,7 @@ test("append(Function) with incoming value", function() {
|
||||
});
|
||||
|
||||
test("append the same fragment with events (Bug #6997, 5566)", function () {
|
||||
var doExtra = !jQuery.support.noCloneEvent && document.fireEvent;
|
||||
var doExtra = !jQuery.support.noCloneEvent && document["fireEvent"];
|
||||
expect(2 + (doExtra ? 1 : 0));
|
||||
stop();
|
||||
|
||||
@ -783,11 +783,11 @@ var testPrepend = function(val) {
|
||||
};
|
||||
|
||||
test("prepend(String|Element|Array<Element>|jQuery)", function() {
|
||||
testPrepend(bareObj);
|
||||
testPrepend(manipulationBareObj);
|
||||
});
|
||||
|
||||
test("prepend(Function)", function() {
|
||||
testPrepend(functionReturningObj);
|
||||
testPrepend(manipulationFunctionReturningObj);
|
||||
});
|
||||
|
||||
test("prepend(Function) with incoming value", function() {
|
||||
@ -902,11 +902,11 @@ var testBefore = function(val) {
|
||||
};
|
||||
|
||||
test("before(String|Element|Array<Element>|jQuery)", function() {
|
||||
testBefore(bareObj);
|
||||
testBefore(manipulationBareObj);
|
||||
});
|
||||
|
||||
test("before(Function)", function() {
|
||||
testBefore(functionReturningObj);
|
||||
testBefore(manipulationFunctionReturningObj);
|
||||
});
|
||||
|
||||
test("before and after w/ empty object (#10812)", function() {
|
||||
@ -971,11 +971,11 @@ var testAfter = function(val) {
|
||||
};
|
||||
|
||||
test("after(String|Element|Array<Element>|jQuery)", function() {
|
||||
testAfter(bareObj);
|
||||
testAfter(manipulationBareObj);
|
||||
});
|
||||
|
||||
test("after(Function)", function() {
|
||||
testAfter(functionReturningObj);
|
||||
testAfter(manipulationFunctionReturningObj);
|
||||
});
|
||||
|
||||
test("insertAfter(String|Element|Array<Element>|jQuery)", function() {
|
||||
@ -1089,11 +1089,11 @@ var testReplaceWith = function(val) {
|
||||
};
|
||||
|
||||
test("replaceWith(String|Element|Array<Element>|jQuery)", function() {
|
||||
testReplaceWith(bareObj);
|
||||
testReplaceWith(manipulationBareObj);
|
||||
});
|
||||
|
||||
test("replaceWith(Function)", function() {
|
||||
testReplaceWith(functionReturningObj);
|
||||
testReplaceWith(manipulationFunctionReturningObj);
|
||||
|
||||
expect(23);
|
||||
|
||||
@ -1259,7 +1259,7 @@ test("clone()", function() {
|
||||
equal( clone.html(), div.html(), "Element contents cloned" );
|
||||
equal( clone[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
|
||||
|
||||
div = jQuery("<div/>").data({ a: true });
|
||||
div = jQuery("<div/>").data({ "a": true });
|
||||
clone = div.clone(true);
|
||||
equal( clone.data("a"), true, "Data cloned." );
|
||||
clone.data("a", false);
|
||||
@ -1354,7 +1354,7 @@ test("html(undefined)", function() {
|
||||
var testHtml = function(valueObj) {
|
||||
expect(35);
|
||||
|
||||
jQuery.scriptorder = 0;
|
||||
jQuery["scriptorder"] = 0;
|
||||
|
||||
var div = jQuery("#qunit-fixture > div");
|
||||
div.html(valueObj("<b>test</b>"));
|
||||
@ -1429,11 +1429,11 @@ var testHtml = function(valueObj) {
|
||||
};
|
||||
|
||||
test("html(String)", function() {
|
||||
testHtml(bareObj);
|
||||
testHtml(manipulationBareObj);
|
||||
});
|
||||
|
||||
test("html(Function)", function() {
|
||||
testHtml(functionReturningObj);
|
||||
testHtml(manipulationFunctionReturningObj);
|
||||
|
||||
expect(37);
|
||||
|
||||
|
@ -2,6 +2,13 @@ if ( jQuery.fn.offset ) {
|
||||
|
||||
module("offset", { teardown: moduleTeardown });
|
||||
|
||||
/*
|
||||
Closure-compiler will roll static methods off of the jQuery object and so they will
|
||||
not be passed with the jQuery object across the windows. To differentiate this, the
|
||||
testIframe callbacks use the "$" symbol to refer to the jQuery object passed from
|
||||
the iframe window and the "jQuery" symbol is used to access any static methods.
|
||||
*/
|
||||
|
||||
test("disconnected node", function() {
|
||||
expect(2);
|
||||
|
||||
@ -23,7 +30,7 @@ testIframe("offset/absolute", "absolute", function($, iframe) {
|
||||
// this insures that the results will be wrong
|
||||
// if the offset method is using the scroll offset
|
||||
// of the parent window
|
||||
forceScroll = jQuery("<div>").css({ width: 2000, height: 2000 });
|
||||
forceScroll = jQuery("<div>").css({ "width": 2000, "height": 2000 });
|
||||
forceScroll.appendTo("body");
|
||||
|
||||
window.scrollTo(200, 200);
|
||||
@ -36,255 +43,257 @@ testIframe("offset/absolute", "absolute", function($, iframe) {
|
||||
|
||||
// get offset
|
||||
tests = [
|
||||
{ id: "#absolute-1", top: 1, left: 1 }
|
||||
{ "id": "#absolute-1", "top": 1, "left": 1 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equal( jQuery( this.id, doc ).offset().top, this.top, "jQuery('" + this.id + "').offset().top" );
|
||||
equal( jQuery( this.id, doc ).offset().left, this.left, "jQuery('" + this.id + "').offset().left" );
|
||||
equal( jQuery( this["id"], doc ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
||||
equal( jQuery( this["id"], doc ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
||||
});
|
||||
|
||||
|
||||
// get position
|
||||
tests = [
|
||||
{ id: "#absolute-1", top: 0, left: 0 }
|
||||
{ "id": "#absolute-1", "top": 0, "left": 0 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equal( jQuery( this.id, doc ).position().top, this.top, "jQuery('" + this.id + "').position().top" );
|
||||
equal( jQuery( this.id, doc ).position().left, this.left, "jQuery('" + this.id + "').position().left" );
|
||||
equal( jQuery( this["id"], doc ).position().top, this["top"], "jQuery('" + this["id"] + "').position().top" );
|
||||
equal( jQuery( this["id"], doc ).position().left, this["left"], "jQuery('" + this["id"] + "').position().left" );
|
||||
});
|
||||
|
||||
forceScroll.remove();
|
||||
});
|
||||
|
||||
testIframe("offset/absolute", "absolute", function( jQuery ) {
|
||||
testIframe("offset/absolute", "absolute", function( $ ) {
|
||||
expect(178);
|
||||
|
||||
// get offset tests
|
||||
var 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 },
|
||||
{ id: "#absolute-2", top: 20, left: 20 }
|
||||
{ "id": "#absolute-1", "top": 1, "left": 1 },
|
||||
{ "id": "#absolute-1-1", "top": 5, "left": 5 },
|
||||
{ "id": "#absolute-1-1-1", "top": 9, "left": 9 },
|
||||
{ "id": "#absolute-2", "top": 20, "left": 20 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equal( jQuery( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset().top" );
|
||||
equal( jQuery( this.id ).offset().left, this.left, "jQuery('" + this.id + "').offset().left" );
|
||||
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
||||
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
||||
});
|
||||
|
||||
|
||||
// get position
|
||||
tests = [
|
||||
{ id: "#absolute-1", top: 0, left: 0 },
|
||||
{ id: "#absolute-1-1", top: 1, left: 1 },
|
||||
{ id: "#absolute-1-1-1", top: 1, left: 1 },
|
||||
{ id: "#absolute-2", top: 19, left: 19 }
|
||||
{ "id": "#absolute-1", "top": 0, "left": 0 },
|
||||
{ "id": "#absolute-1-1", "top": 1, "left": 1 },
|
||||
{ "id": "#absolute-1-1-1", "top": 1, "left": 1 },
|
||||
{ "id": "#absolute-2", "top": 19, "left": 19 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equal( jQuery( this.id ).position().top, this.top, "jQuery('" + this.id + "').position().top" );
|
||||
equal( jQuery( this.id ).position().left, this.left, "jQuery('" + this.id + "').position().left" );
|
||||
equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["id"] + "').position().top" );
|
||||
equal( $( this["id"] ).position().left, this["left"], "jQuery('" + this["id"] + "').position().left" );
|
||||
});
|
||||
|
||||
// test #5781
|
||||
var offset = jQuery( "#positionTest" ).offset({ top: 10, left: 10 }).offset();
|
||||
var 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." );
|
||||
|
||||
|
||||
// set offset
|
||||
tests = [
|
||||
{ id: "#absolute-2", top: 30, left: 30 },
|
||||
{ id: "#absolute-2", top: 10, left: 10 },
|
||||
{ id: "#absolute-2", top: -1, left: -1 },
|
||||
{ id: "#absolute-2", top: 19, left: 19 },
|
||||
{ id: "#absolute-1-1-1", top: 15, left: 15 },
|
||||
{ id: "#absolute-1-1-1", top: 5, left: 5 },
|
||||
{ id: "#absolute-1-1-1", top: -1, left: -1 },
|
||||
{ id: "#absolute-1-1-1", top: 9, left: 9 },
|
||||
{ id: "#absolute-1-1", top: 10, left: 10 },
|
||||
{ id: "#absolute-1-1", top: 0, left: 0 },
|
||||
{ id: "#absolute-1-1", top: -1, left: -1 },
|
||||
{ id: "#absolute-1-1", top: 5, left: 5 },
|
||||
{ id: "#absolute-1", top: 2, left: 2 },
|
||||
{ id: "#absolute-1", top: 0, left: 0 },
|
||||
{ id: "#absolute-1", top: -1, left: -1 },
|
||||
{ id: "#absolute-1", top: 1, left: 1 }
|
||||
{ "id": "#absolute-2", "top": 30, "left": 30 },
|
||||
{ "id": "#absolute-2", "top": 10, "left": 10 },
|
||||
{ "id": "#absolute-2", "top": -1, "left": -1 },
|
||||
{ "id": "#absolute-2", "top": 19, "left": 19 },
|
||||
{ "id": "#absolute-1-1-1", "top": 15, "left": 15 },
|
||||
{ "id": "#absolute-1-1-1", "top": 5, "left": 5 },
|
||||
{ "id": "#absolute-1-1-1", "top": -1, "left": -1 },
|
||||
{ "id": "#absolute-1-1-1", "top": 9, "left": 9 },
|
||||
{ "id": "#absolute-1-1", "top": 10, "left": 10 },
|
||||
{ "id": "#absolute-1-1", "top": 0, "left": 0 },
|
||||
{ "id": "#absolute-1-1", "top": -1, "left": -1 },
|
||||
{ "id": "#absolute-1-1", "top": 5, "left": 5 },
|
||||
{ "id": "#absolute-1", "top": 2, "left": 2 },
|
||||
{ "id": "#absolute-1", "top": 0, "left": 0 },
|
||||
{ "id": "#absolute-1", "top": -1, "left": -1 },
|
||||
{ "id": "#absolute-1", "top": 1, "left": 1 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
jQuery( this.id ).offset({ top: this.top, left: this.left });
|
||||
equal( jQuery( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset({ top: " + this.top + " })" );
|
||||
equal( jQuery( this.id ).offset().left, this.left, "jQuery('" + this.id + "').offset({ left: " + this.left + " })" );
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"] });
|
||||
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
|
||||
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
|
||||
|
||||
var top = this.top, left = this.left;
|
||||
var top = this["top"], left = this["left"];
|
||||
|
||||
jQuery( this.id ).offset(function(i, val){
|
||||
$( this["id"] ).offset(function(i, val){
|
||||
equal( val.top, top, "Verify incoming top position." );
|
||||
equal( val.left, left, "Verify incoming top position." );
|
||||
return { top: top + 1, left: left + 1 };
|
||||
return { "top": top + 1, "left": left + 1 };
|
||||
});
|
||||
equal( jQuery( this.id ).offset().top, this.top + 1, "jQuery('" + this.id + "').offset({ top: " + (this.top + 1) + " })" );
|
||||
equal( jQuery( this.id ).offset().left, this.left + 1, "jQuery('" + this.id + "').offset({ left: " + (this.left + 1) + " })" );
|
||||
equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + " })" );
|
||||
equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + " })" );
|
||||
|
||||
jQuery( this.id )
|
||||
.offset({ left: this.left + 2 })
|
||||
.offset({ top: this.top + 2 });
|
||||
equal( jQuery( this.id ).offset().top, this.top + 2, "Setting one property at a time." );
|
||||
equal( jQuery( this.id ).offset().left, this.left + 2, "Setting one property at a time." );
|
||||
$( this["id"] )
|
||||
.offset({ "left": this["left"] + 2 })
|
||||
.offset({ "top": this["top"] + 2 });
|
||||
equal( $( this["id"] ).offset().top, this["top"] + 2, "Setting one property at a time." );
|
||||
equal( $( this["id"] ).offset().left, this["left"] + 2, "Setting one property at a time." );
|
||||
|
||||
jQuery( this.id ).offset({ top: this.top, left: this.left, using: function( props ) {
|
||||
jQuery( this ).css({
|
||||
top: props.top + 1,
|
||||
left: props.left + 1
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"], "using": function( props ) {
|
||||
$( this ).css({
|
||||
"top": props.top + 1,
|
||||
"left": props.left + 1
|
||||
});
|
||||
}});
|
||||
equal( jQuery( this.id ).offset().top, this.top + 1, "jQuery('" + this.id + "').offset({ top: " + (this.top + 1) + ", using: fn })" );
|
||||
equal( jQuery( this.id ).offset().left, this.left + 1, "jQuery('" + this.id + "').offset({ left: " + (this.left + 1) + ", using: fn })" );
|
||||
equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
|
||||
equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
|
||||
});
|
||||
});
|
||||
|
||||
testIframe("offset/relative", "relative", function( jQuery ) {
|
||||
testIframe("offset/relative", "relative", function( $ ) {
|
||||
expect(60);
|
||||
|
||||
// IE is collapsing the top margin of 1px; detect and adjust accordingly
|
||||
var ie = jQuery("#relative-1").offset().top === 6;
|
||||
var ie = $("#relative-1").offset().top === 6;
|
||||
|
||||
// get offset
|
||||
var 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 }
|
||||
{ "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 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equal( jQuery( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset().top" );
|
||||
equal( jQuery( this.id ).offset().left, this.left, "jQuery('" + this.id + "').offset().left" );
|
||||
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
||||
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
||||
});
|
||||
|
||||
|
||||
// get position
|
||||
tests = [
|
||||
{ id: "#relative-1", top: ie ? 5 : 6, left: 6 },
|
||||
{ id: "#relative-1-1", top: ie ? 4 : 5, left: 5 },
|
||||
{ id: "#relative-2", top: ie ? 140 : 141, left: 26 }
|
||||
{ "id": "#relative-1", "top": ie ? 5 : 6, "left": 6 },
|
||||
{ "id": "#relative-1-1", "top": ie ? 4 : 5, "left": 5 },
|
||||
{ "id": "#relative-2", "top": ie ? 140 : 141, "left": 26 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equal( jQuery( this.id ).position().top, this.top, "jQuery('" + this.id + "').position().top" );
|
||||
equal( jQuery( this.id ).position().left, this.left, "jQuery('" + this.id + "').position().left" );
|
||||
equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["id"] + "').position().top" );
|
||||
equal( $( this["id"] ).position().left, this["left"], "jQuery('" + this["id"] + "').position().left" );
|
||||
});
|
||||
|
||||
|
||||
// set offset
|
||||
tests = [
|
||||
{ id: "#relative-2", top: 200, left: 50 },
|
||||
{ id: "#relative-2", top: 100, left: 10 },
|
||||
{ id: "#relative-2", top: -5, left: -5 },
|
||||
{ id: "#relative-2", top: 142, left: 27 },
|
||||
{ id: "#relative-1-1", top: 100, left: 100 },
|
||||
{ id: "#relative-1-1", top: 5, left: 5 },
|
||||
{ id: "#relative-1-1", top: -1, left: -1 },
|
||||
{ id: "#relative-1-1", top: 15, left: 15 },
|
||||
{ id: "#relative-1", top: 100, left: 100 },
|
||||
{ id: "#relative-1", top: 0, left: 0 },
|
||||
{ id: "#relative-1", top: -1, left: -1 },
|
||||
{ id: "#relative-1", top: 7, left: 7 }
|
||||
{ "id": "#relative-2", "top": 200, "left": 50 },
|
||||
{ "id": "#relative-2", "top": 100, "left": 10 },
|
||||
{ "id": "#relative-2", "top": -5, "left": -5 },
|
||||
{ "id": "#relative-2", "top": 142, "left": 27 },
|
||||
{ "id": "#relative-1-1", "top": 100, "left": 100 },
|
||||
{ "id": "#relative-1-1", "top": 5, "left": 5 },
|
||||
{ "id": "#relative-1-1", "top": -1, "left": -1 },
|
||||
{ "id": "#relative-1-1", "top": 15, "left": 15 },
|
||||
{ "id": "#relative-1", "top": 100, "left": 100 },
|
||||
{ "id": "#relative-1", "top": 0, "left": 0 },
|
||||
{ "id": "#relative-1", "top": -1, "left": -1 },
|
||||
{ "id": "#relative-1", "top": 7, "left": 7 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
jQuery( this.id ).offset({ top: this.top, left: this.left });
|
||||
equal( jQuery( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset({ top: " + this.top + " })" );
|
||||
equal( jQuery( this.id ).offset().left, this.left, "jQuery('" + this.id + "').offset({ left: " + this.left + " })" );
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"] });
|
||||
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
|
||||
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
|
||||
|
||||
jQuery( this.id ).offset({ top: this.top, left: this.left, using: function( props ) {
|
||||
jQuery( this ).css({
|
||||
top: props.top + 1,
|
||||
left: props.left + 1
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"], "using": function( props ) {
|
||||
$( this ).css({
|
||||
"top": props.top + 1,
|
||||
"left": props.left + 1
|
||||
});
|
||||
}});
|
||||
equal( jQuery( this.id ).offset().top, this.top + 1, "jQuery('" + this.id + "').offset({ top: " + (this.top + 1) + ", using: fn })" );
|
||||
equal( jQuery( this.id ).offset().left, this.left + 1, "jQuery('" + this.id + "').offset({ left: " + (this.left + 1) + ", using: fn })" );
|
||||
equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
|
||||
equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
|
||||
});
|
||||
});
|
||||
|
||||
testIframe("offset/static", "static", function( jQuery ) {
|
||||
testIframe("offset/static", "static", function( $ ) {
|
||||
|
||||
// IE is collapsing the top margin of 1px; detect and adjust accordingly
|
||||
var ie = jQuery("#static-1").offset().top === 6,
|
||||
var ie = $("#static-1").offset().top === 6,
|
||||
swarmy = document.documentMode === 8 && window.location.search.indexOf("swarmURL") >= 0;
|
||||
|
||||
expect( swarmy? 68 : 80 );
|
||||
|
||||
// get offset
|
||||
var 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 }
|
||||
{ "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 }
|
||||
];
|
||||
if ( !swarmy ) {
|
||||
tests.push({ id: "#static-2", top: ie ? 121 : 122, left: 7 });
|
||||
tests.push({ "id": "#static-2", "top": ie ? 121 : 122, left: 7 });
|
||||
}
|
||||
jQuery.each( tests, function() {
|
||||
equal( jQuery( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset().top" );
|
||||
equal( jQuery( this.id ).offset().left, this.left, "jQuery('" + this.id + "').offset().left" );
|
||||
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
||||
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
||||
});
|
||||
|
||||
|
||||
// get position
|
||||
tests = [
|
||||
{ id: "#static-1", top: ie ? 5 : 6, left: 6 },
|
||||
{ id: "#static-1-1", top: ie ? 12 : 14, left: 14 },
|
||||
{ id: "#static-1-1-1", top: ie ? 19 : 22, left: 22 }
|
||||
{ "id": "#static-1", "top": ie ? 5 : 6, "left": 6 },
|
||||
{ "id": "#static-1-1", "top": ie ? 12 : 14, "left": 14 },
|
||||
{ "id": "#static-1-1-1", "top": ie ? 19 : 22, "left": 22 }
|
||||
|
||||
];
|
||||
if ( !swarmy ) {
|
||||
tests.push({ id: "#static-2", top: ie ? 120 : 121, left: 6 });
|
||||
tests.push({ "id": "#static-2", "top": ie ? 120 : 121, "left": 6 });
|
||||
}
|
||||
jQuery.each( tests, function() {
|
||||
equal( jQuery( this.id ).position().top, this.top, "jQuery('" + this.top + "').position().top" );
|
||||
equal( jQuery( this.id ).position().left, this.left, "jQuery('" + this.left +"').position().left" );
|
||||
equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["top"] + "').position().top" );
|
||||
equal( $( this["id"] ).position().left, this["left"], "jQuery('" + this["left"] +"').position().left" );
|
||||
});
|
||||
|
||||
|
||||
// set offset
|
||||
tests = [
|
||||
{ id: "#static-2", top: 200, left: 200 },
|
||||
{ id: "#static-2", top: 100, left: 100 },
|
||||
{ id: "#static-1-1-1", top: 50, left: 50 },
|
||||
{ id: "#static-1-1-1", top: 10, left: 10 },
|
||||
{ id: "#static-1-1-1", top: -1, left: -1 },
|
||||
{ id: "#static-1-1-1", top: 22, left: 22 },
|
||||
{ id: "#static-1-1", top: 25, left: 25 },
|
||||
{ id: "#static-1-1", top: 10, left: 10 },
|
||||
{ id: "#static-1-1", top: -3, left: -3 },
|
||||
{ id: "#static-1-1", top: 14, left: 14 },
|
||||
{ id: "#static-1", top: 30, left: 30 },
|
||||
{ id: "#static-1", top: 2, left: 2 },
|
||||
{ id: "#static-1", top: -2, left: -2 },
|
||||
{ id: "#static-1", top: 7, left: 7 }
|
||||
{ "id": "#static-2", "top": 200, "left": 200 },
|
||||
{ "id": "#static-2", "top": 100, "left": 100 },
|
||||
{ "id": "#static-2", "top": -2, "left": -2 },
|
||||
{ "id": "#static-2", "top": 121, "left": 6 },
|
||||
{ "id": "#static-1-1-1", "top": 50, "left": 50 },
|
||||
{ "id": "#static-1-1-1", "top": 10, "left": 10 },
|
||||
{ "id": "#static-1-1-1", "top": -1, "left": -1 },
|
||||
{ "id": "#static-1-1-1", "top": 22, "left": 22 },
|
||||
{ "id": "#static-1-1", "top": 25, "left": 25 },
|
||||
{ "id": "#static-1-1", "top": 10, "left": 10 },
|
||||
{ "id": "#static-1-1", "top": -3, "left": -3 },
|
||||
{ "id": "#static-1-1", "top": 14, "left": 14 },
|
||||
{ "id": "#static-1", "top": 30, "left": 30 },
|
||||
{ "id": "#static-1", "top": 2, "left": 2 }
|
||||
|
||||
];
|
||||
if ( !swarmy ) {
|
||||
tests.push(
|
||||
{ id: "#static-2", top: -2, left: -2 },
|
||||
{ id: "#static-2", top: 121, left: 6 }
|
||||
{ "id": "#static-1", "top": -2, "left": -2 },
|
||||
{ "id": "#static-1", "top": 7, "left": 7 }
|
||||
);
|
||||
}
|
||||
jQuery.each( tests, function() {
|
||||
jQuery( this.id ).offset({ top: this.top, left: this.left });
|
||||
equal( jQuery( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset({ top: " + this.top + " })" );
|
||||
equal( jQuery( this.id ).offset().left, this.left, "jQuery('" + this.id + "').offset({ left: " + this.left + " })" );
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"] });
|
||||
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
|
||||
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
|
||||
|
||||
jQuery( this.id ).offset({ top: this.top, left: this.left, using: function( props ) {
|
||||
jQuery( this ).css({
|
||||
top: props.top + 1,
|
||||
left: props.left + 1
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"], "using": function( props ) {
|
||||
$( this ).css({
|
||||
"top": props.top + 1,
|
||||
"left": props.left + 1
|
||||
});
|
||||
}});
|
||||
equal( jQuery( this.id ).offset().top, this.top + 1, "jQuery('" + this.id + "').offset({ top: " + (this.top + 1) + ", using: fn })" );
|
||||
equal( jQuery( this.id ).offset().left, this.left + 1, "jQuery('" + this.id + "').offset({ left: " + (this.left + 1) + ", using: fn })" );
|
||||
equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
|
||||
equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
|
||||
});
|
||||
});
|
||||
|
||||
testIframe("offset/fixed", "fixed", function( jQuery ) {
|
||||
testIframe("offset/fixed", "fixed", function( $ ) {
|
||||
expect(30);
|
||||
|
||||
var tests = [
|
||||
{ id: "#fixed-1", top: 1001, left: 1001 },
|
||||
{ id: "#fixed-2", top: 1021, left: 1021 }
|
||||
{ "id": "#fixed-1", "top": 1001, "left": 1001 },
|
||||
{ "id": "#fixed-2", "top": 1021, "left": 1021 }
|
||||
];
|
||||
|
||||
jQuery.each( tests, function() {
|
||||
@ -293,8 +302,8 @@ testIframe("offset/fixed", "fixed", function( jQuery ) {
|
||||
ok( true, "Browser doesn't support scroll position." );
|
||||
|
||||
} else if ( jQuery.offset.supportsFixedPosition ) {
|
||||
equal( jQuery( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset().top" );
|
||||
equal( jQuery( this.id ).offset().left, this.left, "jQuery('" + this.id + "').offset().left" );
|
||||
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
||||
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
||||
} else {
|
||||
// need to have same number of assertions
|
||||
ok( true, "Fixed position is not supported" );
|
||||
@ -303,28 +312,28 @@ testIframe("offset/fixed", "fixed", function( jQuery ) {
|
||||
});
|
||||
|
||||
tests = [
|
||||
{ id: "#fixed-1", top: 100, left: 100 },
|
||||
{ id: "#fixed-1", top: 0, left: 0 },
|
||||
{ id: "#fixed-1", top: -4, left: -4 },
|
||||
{ id: "#fixed-2", top: 200, left: 200 },
|
||||
{ id: "#fixed-2", top: 0, left: 0 },
|
||||
{ id: "#fixed-2", top: -5, left: -5 }
|
||||
{ "id": "#fixed-1", "top": 100, "left": 100 },
|
||||
{ "id": "#fixed-1", "top": 0, "left": 0 },
|
||||
{ "id": "#fixed-1", "top": -4, "left": -4 },
|
||||
{ "id": "#fixed-2", "top": 200, "left": 200 },
|
||||
{ "id": "#fixed-2", "top": 0, "left": 0 },
|
||||
{ "id": "#fixed-2", "top": -5, "left": -5 }
|
||||
];
|
||||
|
||||
jQuery.each( tests, function() {
|
||||
if ( jQuery.offset.supportsFixedPosition ) {
|
||||
jQuery( this.id ).offset({ top: this.top, left: this.left });
|
||||
equal( jQuery( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset({ top: " + this.top + " })" );
|
||||
equal( jQuery( this.id ).offset().left, this.left, "jQuery('" + this.id + "').offset({ left: " + this.left + " })" );
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"] });
|
||||
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
|
||||
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
|
||||
|
||||
jQuery( this.id ).offset({ top: this.top, left: this.left, using: function( props ) {
|
||||
jQuery( this ).css({
|
||||
top: props.top + 1,
|
||||
left: props.left + 1
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"], "using": function( props ) {
|
||||
$( this ).css({
|
||||
"top": props.top + 1,
|
||||
"left": props.left + 1
|
||||
});
|
||||
}});
|
||||
equal( jQuery( this.id ).offset().top, this.top + 1, "jQuery('" + this.id + "').offset({ top: " + (this.top + 1) + ", using: fn })" );
|
||||
equal( jQuery( this.id ).offset().left, this.left + 1, "jQuery('" + this.id + "').offset({ left: " + (this.left + 1) + ", using: fn })" );
|
||||
equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
|
||||
equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
|
||||
} else {
|
||||
// need to have same number of assertions
|
||||
ok( true, "Fixed position is not supported" );
|
||||
@ -335,7 +344,7 @@ testIframe("offset/fixed", "fixed", function( jQuery ) {
|
||||
});
|
||||
|
||||
// Bug 8316
|
||||
var $noTopLeft = jQuery("#fixed-no-top-left");
|
||||
var $noTopLeft = $("#fixed-no-top-left");
|
||||
if ( jQuery.offset.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" );
|
||||
@ -346,39 +355,41 @@ testIframe("offset/fixed", "fixed", function( jQuery ) {
|
||||
}
|
||||
});
|
||||
|
||||
testIframe("offset/table", "table", function( jQuery ) {
|
||||
testIframe("offset/table", "table", function( $ ) {
|
||||
expect(4);
|
||||
|
||||
equal( jQuery("#table-1").offset().top, 6, "jQuery('#table-1').offset().top" );
|
||||
equal( jQuery("#table-1").offset().left, 6, "jQuery('#table-1').offset().left" );
|
||||
equal( $("#table-1").offset().top, 6, "jQuery('#table-1').offset().top" );
|
||||
equal( $("#table-1").offset().left, 6, "jQuery('#table-1').offset().left" );
|
||||
|
||||
equal( jQuery("#th-1").offset().top, 10, "jQuery('#th-1').offset().top" );
|
||||
equal( jQuery("#th-1").offset().left, 10, "jQuery('#th-1').offset().left" );
|
||||
equal( $("#th-1").offset().top, 10, "jQuery('#th-1').offset().top" );
|
||||
equal( $("#th-1").offset().left, 10, "jQuery('#th-1').offset().left" );
|
||||
});
|
||||
|
||||
testIframe("offset/scroll", "scroll", function( jQuery, win ) {
|
||||
expect(26);
|
||||
testIframe("offset/scroll", "scroll", function( $, win ) {
|
||||
expect(24);
|
||||
|
||||
// IE is collapsing the top margin of 1px; detect and adjust accordingly
|
||||
var ie = jQuery("#scroll-1").offset().top == 6;
|
||||
var ie = $("#scroll-1").offset().top == 6;
|
||||
|
||||
equal( jQuery("#scroll-1").offset().top, ie ? 6 : 7, "jQuery('#scroll-1').offset().top" );
|
||||
equal( jQuery("#scroll-1").offset().left, 7, "jQuery('#scroll-1').offset().left" );
|
||||
// IE is collapsing the top margin of 1px
|
||||
equal( $("#scroll-1").offset().top, ie ? 6 : 7, "jQuery('#scroll-1').offset().top" );
|
||||
equal( $("#scroll-1").offset().left, 7, "jQuery('#scroll-1').offset().left" );
|
||||
|
||||
equal( jQuery("#scroll-1-1").offset().top, ie ? 9 : 11, "jQuery('#scroll-1-1').offset().top" );
|
||||
equal( jQuery("#scroll-1-1").offset().left, 11, "jQuery('#scroll-1-1').offset().left" );
|
||||
// IE is collapsing the top margin of 1px
|
||||
equal( $("#scroll-1-1").offset().top, ie ? 9 : 11, "jQuery('#scroll-1-1').offset().top" );
|
||||
equal( $("#scroll-1-1").offset().left, 11, "jQuery('#scroll-1-1').offset().left" );
|
||||
|
||||
|
||||
// scroll offset tests .scrollTop/Left
|
||||
equal( jQuery("#scroll-1").scrollTop(), 5, "jQuery('#scroll-1').scrollTop()" );
|
||||
equal( jQuery("#scroll-1").scrollLeft(), 5, "jQuery('#scroll-1').scrollLeft()" );
|
||||
equal( $("#scroll-1").scrollTop(), 5, "jQuery('#scroll-1').scrollTop()" );
|
||||
equal( $("#scroll-1").scrollLeft(), 5, "jQuery('#scroll-1').scrollLeft()" );
|
||||
|
||||
equal( jQuery("#scroll-1-1").scrollTop(), 0, "jQuery('#scroll-1-1').scrollTop()" );
|
||||
equal( jQuery("#scroll-1-1").scrollLeft(), 0, "jQuery('#scroll-1-1').scrollLeft()" );
|
||||
equal( $("#scroll-1-1").scrollTop(), 0, "jQuery('#scroll-1-1').scrollTop()" );
|
||||
equal( $("#scroll-1-1").scrollLeft(), 0, "jQuery('#scroll-1-1').scrollLeft()" );
|
||||
|
||||
// scroll method chaining
|
||||
equal( jQuery("#scroll-1").scrollTop(undefined).scrollTop(), 5, ".scrollTop(undefined) is chainable (#5571)" );
|
||||
equal( jQuery("#scroll-1").scrollLeft(undefined).scrollLeft(), 5, ".scrollLeft(undefined) is chainable (#5571)" );
|
||||
equal( $("#scroll-1").scrollTop(undefined).scrollTop(), 5, ".scrollTop(undefined) is chainable (#5571)" );
|
||||
equal( $("#scroll-1").scrollLeft(undefined).scrollLeft(), 5, ".scrollLeft(undefined) is chainable (#5571)" );
|
||||
|
||||
win.name = "test";
|
||||
|
||||
@ -389,46 +400,40 @@ testIframe("offset/scroll", "scroll", function( jQuery, win ) {
|
||||
ok( true, "Browser doesn't support scroll position." );
|
||||
ok( true, "Browser doesn't support scroll position." );
|
||||
} else {
|
||||
equal( jQuery(win).scrollTop(), 1000, "jQuery(window).scrollTop()" );
|
||||
equal( jQuery(win).scrollLeft(), 1000, "jQuery(window).scrollLeft()" );
|
||||
equal( $(win).scrollTop(), 1000, "jQuery(window).scrollTop()" );
|
||||
equal( $(win).scrollLeft(), 1000, "jQuery(window).scrollLeft()" );
|
||||
|
||||
equal( jQuery(win.document).scrollTop(), 1000, "jQuery(document).scrollTop()" );
|
||||
equal( jQuery(win.document).scrollLeft(), 1000, "jQuery(document).scrollLeft()" );
|
||||
equal( $(win.document).scrollTop(), 1000, "jQuery(document).scrollTop()" );
|
||||
equal( $(win.document).scrollLeft(), 1000, "jQuery(document).scrollLeft()" );
|
||||
}
|
||||
|
||||
// test jQuery using parent window/document
|
||||
// jQuery reference here is in the iframe
|
||||
window.scrollTo(0,0);
|
||||
equal( jQuery(window).scrollTop(), 0, "jQuery(window).scrollTop() other window" );
|
||||
equal( jQuery(window).scrollLeft(), 0, "jQuery(window).scrollLeft() other window" );
|
||||
equal( jQuery(document).scrollTop(), 0, "jQuery(window).scrollTop() other document" );
|
||||
equal( jQuery(document).scrollLeft(), 0, "jQuery(window).scrollLeft() other document" );
|
||||
equal( $(window).scrollTop(), 0, "jQuery(window).scrollTop() other window" );
|
||||
equal( $(window).scrollLeft(), 0, "jQuery(window).scrollLeft() other window" );
|
||||
equal( $(document).scrollTop(), 0, "jQuery(window).scrollTop() other document" );
|
||||
equal( $(document).scrollLeft(), 0, "jQuery(window).scrollLeft() other document" );
|
||||
|
||||
// Tests scrollTop/Left with empty jquery objects
|
||||
notEqual( jQuery().scrollTop(100), null, "jQuery().scrollTop(100) testing setter on empty jquery object" );
|
||||
notEqual( jQuery().scrollLeft(100), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" );
|
||||
notEqual( jQuery().scrollTop(null), null, "jQuery().scrollTop(null) testing setter on empty jquery object" );
|
||||
notEqual( jQuery().scrollLeft(null), null, "jQuery().scrollLeft(null) testing setter on empty jquery object" );
|
||||
strictEqual( jQuery().scrollTop(), null, "jQuery().scrollTop(100) testing setter on empty jquery object" );
|
||||
strictEqual( jQuery().scrollLeft(), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" );
|
||||
|
||||
// test setting scroll
|
||||
jQuery( win ).scrollTop( 100 );
|
||||
jQuery( win ).scrollLeft( 101 );
|
||||
equal( jQuery( win ).scrollTop(), 100, "jQuery( win ).scrollTop() testing setter" );
|
||||
equal( jQuery( win ).scrollLeft(), 101, "jQuery( win ).scrollLeft() testing setter" );
|
||||
notEqual( $().scrollTop(100), null, "jQuery().scrollTop(100) testing setter on empty jquery object" );
|
||||
notEqual( $().scrollLeft(100), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" );
|
||||
notEqual( $().scrollTop(null), null, "jQuery().scrollTop(null) testing setter on empty jquery object" );
|
||||
notEqual( $().scrollLeft(null), null, "jQuery().scrollLeft(null) testing setter on empty jquery object" );
|
||||
strictEqual( $().scrollTop(), null, "jQuery().scrollTop(100) testing setter on empty jquery object" );
|
||||
strictEqual( $().scrollLeft(), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" );
|
||||
});
|
||||
|
||||
testIframe("offset/body", "body", function( jQuery ) {
|
||||
testIframe("offset/body", "body", function( $ ) {
|
||||
expect(2);
|
||||
|
||||
equal( jQuery("body").offset().top, 1, "jQuery('#body').offset().top" );
|
||||
equal( jQuery("body").offset().left, 1, "jQuery('#body').offset().left" );
|
||||
equal( $("body").offset().top, 1, "jQuery('#body').offset().top" );
|
||||
equal( $("body").offset().left, 1, "jQuery('#body').offset().left" );
|
||||
});
|
||||
|
||||
test("chaining", function() {
|
||||
expect(3);
|
||||
var coords = { top: 1, left: 1 };
|
||||
var coords = { "top": 1, "left": 1 };
|
||||
equal( jQuery("#absolute-1").offset(coords).selector, "#absolute-1", "offset(coords) returns jQuery object" );
|
||||
equal( jQuery("#non-existent").offset(coords).selector, "#non-existent", "offset(coords) with empty jQuery set returns jQuery object" );
|
||||
equal( jQuery("#absolute-1").offset(undefined).selector, "#absolute-1", "offset(undefined) returns jQuery object (#5571)" );
|
||||
@ -466,15 +471,15 @@ test("fractions (see #7730 and #7885)", function() {
|
||||
|
||||
jQuery('body').append('<div id="fractions"/>');
|
||||
|
||||
var expected = { top: 1000, left: 1000 };
|
||||
var expected = { "top": 1000, "left": 1000 };
|
||||
var div = jQuery('#fractions');
|
||||
|
||||
div.css({
|
||||
position: 'absolute',
|
||||
left: '1000.7432222px',
|
||||
top: '1000.532325px',
|
||||
width: 100,
|
||||
height: 100
|
||||
"position": 'absolute',
|
||||
"left": '1000.7432222px',
|
||||
"top": '1000.532325px',
|
||||
"width": 100,
|
||||
"height": 100
|
||||
});
|
||||
|
||||
div.offset(expected);
|
||||
|
@ -91,7 +91,7 @@ testIframe("selector/html5_selector", "attributes - jQuery.attr", function( jQue
|
||||
* @example t("Check for something", "//[a]", ["foo", "baar"]);
|
||||
* @param {String} a - Assertion name
|
||||
* @param {String} b - Sizzle selector
|
||||
* @param {String} c - Array of ids to construct what is expected
|
||||
* @param {Array} c - Array of ids to construct what is expected
|
||||
*/
|
||||
function t( a, b, c ) {
|
||||
var f = jQuery(b).get(),
|
||||
@ -147,7 +147,8 @@ testIframe("selector/html5_selector", "attributes - jQuery.attr", function( jQue
|
||||
t( "Attribute Exists", "[truespeed]", ["marquee1"]);
|
||||
|
||||
// Enumerated attributes (these are not boolean content attributes)
|
||||
jQuery.each([ "draggable", "contenteditable", "aria-disabled" ], function( i, val ) {
|
||||
jQuery.expandedEach = jQuery.each;
|
||||
jQuery.expandedEach([ "draggable", "contenteditable", "aria-disabled" ], function( i, val ) {
|
||||
t( "Enumerated attribute", "[" + val + "]", ["div1"]);
|
||||
});
|
||||
t( "Enumerated attribute", "[spellcheck]", ["span1"]);
|
||||
@ -157,7 +158,7 @@ testIframe("selector/html5_selector", "attributes - jQuery.attr", function( jQue
|
||||
});
|
||||
|
||||
testIframe("selector/sizzle_cache", "Sizzle cache collides with multiple Sizzles on a page", function( jQuery, window, document ) {
|
||||
var $cached = window.$cached;
|
||||
var $cached = window["$cached"];
|
||||
|
||||
expect(3);
|
||||
deepEqual( $cached('.test a').get(), [ document.getElementById('collision') ], "Select collision anchor with first sizzle" );
|
||||
|
Loading…
Reference in New Issue
Block a user