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