second batch

This commit is contained in:
louisremi 2011-04-11 22:33:29 +02:00
parent cccd092fe0
commit 11adde5127
6 changed files with 460 additions and 460 deletions

View File

@ -180,7 +180,7 @@ jQuery.offset = {
curOffset = curElem.offset(),
curCSSTop = jQuery.css( elem, "top" ),
curCSSLeft = jQuery.css( elem, "left" ),
calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1,
calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
props = {}, curPosition = {}, curTop, curLeft;
// need to be able to calculate position if either top or left is auto and position is either absolute or fixed

View File

@ -14,7 +14,7 @@ test("jQuery.ajax() - success callbacks", function() {
stop();
jQuery('#foo').ajaxStart(function(){
jQuery("#foo").ajaxStart(function(){
ok( true, "ajaxStart" );
}).ajaxStop(function(){
ok( true, "ajaxStop" );
@ -46,7 +46,7 @@ test("jQuery.ajax() - success callbacks - (url, options) syntax", function() {
stop();
setTimeout(function(){
jQuery('#foo').ajaxStart(function(){
jQuery("#foo").ajaxStart(function(){
ok( true, "ajaxStart" );
}).ajaxStop(function(){
ok( true, "ajaxStop" );
@ -78,7 +78,7 @@ test("jQuery.ajax() - success callbacks (late binding)", function() {
stop();
setTimeout(function(){
jQuery('#foo').ajaxStart(function(){
jQuery("#foo").ajaxStart(function(){
ok( true, "ajaxStart" );
}).ajaxStop(function(){
ok( true, "ajaxStop" );
@ -111,7 +111,7 @@ test("jQuery.ajax() - success callbacks (oncomplete binding)", function() {
stop();
setTimeout(function(){
jQuery('#foo').ajaxStart(function(){
jQuery("#foo").ajaxStart(function(){
ok( true, "ajaxStart" );
}).ajaxStop(function(){
ok( true, "ajaxStop" );
@ -147,7 +147,7 @@ test("jQuery.ajax() - success callbacks (very late binding)", function() {
stop();
setTimeout(function(){
jQuery('#foo').ajaxStart(function(){
jQuery("#foo").ajaxStart(function(){
ok( true, "ajaxStart" );
}).ajaxStop(function(){
ok( true, "ajaxStop" );
@ -214,7 +214,7 @@ test("jQuery.ajax() - error callbacks", function() {
expect( 8 );
stop();
jQuery('#foo').ajaxStart(function(){
jQuery("#foo").ajaxStart(function(){
ok( true, "ajaxStart" );
}).ajaxStop(function(){
ok( true, "ajaxStop" );
@ -247,10 +247,10 @@ test( "jQuery.ajax - multiple method signatures introduced in 1.5 ( #8107)", fun
stop();
jQuery.when(
jQuery.ajax().success(function() { ok( true, 'With no arguments' ); }),
jQuery.ajax('data/name.html').success(function() { ok( true, 'With only string URL argument' ); }),
jQuery.ajax('data/name.html', {} ).success(function() { ok( true, 'With string URL param and map' ); }),
jQuery.ajax({ url: 'data/name.html'} ).success(function() { ok( true, 'With only map' ); })
jQuery.ajax().success(function() { ok( true, "With no arguments" ); }),
jQuery.ajax("data/name.html").success(function() { ok( true, "With only string URL argument" ); }),
jQuery.ajax("data/name.html", {} ).success(function() { ok( true, "With string URL param and map" ); }),
jQuery.ajax({ url: "data/name.html"} ).success(function() { ok( true, "With only map" ); })
).then( start, start );
});
@ -348,7 +348,7 @@ test(".ajax() - headers" , function() {
stop();
jQuery('#foo').ajaxSend(function( evt, xhr ) {
jQuery("#foo").ajaxSend(function( evt, xhr ) {
xhr.setRequestHeader( "ajax-send", "test" );
});
@ -509,7 +509,7 @@ test("jQuery ajax - cross-domain detection", function() {
jQuery.ajax({
dataType: "jsonp",
url: 'app:/path',
url: "app:/path",
beforeSend: function( _ , s ) {
ok( s.crossDomain , "Adobe AIR app:/ URL detected as cross-domain" );
return false;
@ -518,7 +518,7 @@ test("jQuery ajax - cross-domain detection", function() {
jQuery.ajax({
dataType: "jsonp",
url: loc.protocol + '//somewebsitethatdoesnotexist-656329477541.com:' + ( loc.port || 80 ),
url: loc.protocol + "//somewebsitethatdoesnotexist-656329477541.com:" + ( loc.port || 80 ),
beforeSend: function( _ , s ) {
ok( s.crossDomain , "Test different hostnames are detected as cross-domain" );
return false;
@ -559,7 +559,7 @@ test(".load() - 404 error callbacks", function() {
expect( 6 );
stop();
jQuery('#foo').ajaxStart(function(){
jQuery("#foo").ajaxStart(function(){
ok( true, "ajaxStart" );
}).ajaxStop(function(){
ok( true, "ajaxStop" );
@ -583,7 +583,7 @@ test("jQuery.ajax() - abort", function() {
expect( 8 );
stop();
jQuery('#foo').ajaxStart(function(){
jQuery("#foo").ajaxStart(function(){
ok( true, "ajaxStart" );
}).ajaxStop(function(){
ok( true, "ajaxStop" );
@ -628,7 +628,7 @@ test("Ajax events with context", function() {
};
}
jQuery('#foo').add(context)
jQuery("#foo").add(context)
.ajaxSend(event)
.ajaxComplete(event)
.ajaxError(event)
@ -650,7 +650,7 @@ test("Ajax events with context", function() {
complete: function(){
callback("complete").call(this);
jQuery('#foo').add(context).unbind();
jQuery("#foo").add(context).unbind();
jQuery.ajax({
url: url("data/404.html"),
@ -734,7 +734,7 @@ test("jQuery.ajax() - disabled globals", function() {
expect( 3 );
stop();
jQuery('#foo').ajaxStart(function(){
jQuery("#foo").ajaxStart(function(){
ok( false, "ajaxStart" );
}).ajaxStop(function(){
ok( false, "ajaxStop" );
@ -768,9 +768,9 @@ test("jQuery.ajax - xml: non-namespace elements inside namespaced elements", fun
url: url("data/with_fries.xml"),
dataType: "xml",
success: function(resp) {
equals( jQuery("properties", resp).length, 1, 'properties in responseXML' );
equals( jQuery("jsconf", resp).length, 1, 'jsconf in responseXML' );
equals( jQuery("thing", resp).length, 2, 'things in responseXML' );
equals( jQuery("properties", resp).length, 1, "properties in responseXML" );
equals( jQuery("jsconf", resp).length, 1, "jsconf in responseXML" );
equals( jQuery("thing", resp).length, 2, "things in responseXML" );
start();
}
});
@ -783,9 +783,9 @@ test("jQuery.ajax - xml: non-namespace elements inside namespaced elements (over
url: url("data/with_fries_over_jsonp.php"),
dataType: "jsonp xml",
success: function(resp) {
equals( jQuery("properties", resp).length, 1, 'properties in responseXML' );
equals( jQuery("jsconf", resp).length, 1, 'jsconf in responseXML' );
equals( jQuery("thing", resp).length, 2, 'things in responseXML' );
equals( jQuery("properties", resp).length, 1, "properties in responseXML" );
equals( jQuery("jsconf", resp).length, 1, "jsconf in responseXML" );
equals( jQuery("thing", resp).length, 2, "things in responseXML" );
start();
},
error: function(_1,_2,error) {
@ -804,7 +804,7 @@ test("jQuery.ajax - HEAD requests", function() {
type: "HEAD",
success: function(data, status, xhr){
var h = xhr.getAllResponseHeaders();
ok( /Date/i.test(h), 'No Date in HEAD response' );
ok( /Date/i.test(h), "No Date in HEAD response" );
jQuery.ajax({
url: url("data/name.html"),
@ -812,7 +812,7 @@ test("jQuery.ajax - HEAD requests", function() {
type: "HEAD",
success: function(data, status, xhr){
var h = xhr.getAllResponseHeaders();
ok( /Date/i.test(h), 'No Date in HEAD response with data' );
ok( /Date/i.test(h), "No Date in HEAD response with data" );
start();
}
});
@ -891,8 +891,8 @@ test("jQuery.ajax - dataType html", function() {
stop();
var verifyEvaluation = function() {
equals( testFoo, "foo", 'Check if script was evaluated for datatype html' );
equals( foobar, "bar", 'Check if script src was evaluated for datatype html' );
equals( testFoo, "foo", "Check if script was evaluated for datatype html" );
equals( foobar, "bar", "Check if script src was evaluated for datatype html" );
start();
};
@ -902,7 +902,7 @@ test("jQuery.ajax - dataType html", function() {
url: url("data/test.html"),
success: function(data) {
jQuery("#ap").html(data);
ok( data.match(/^html text/), 'Check content for datatype html' );
ok( data.match(/^html text/), "Check content for datatype html" );
setTimeout(verifyEvaluation, 600);
}
});
@ -913,34 +913,34 @@ test("serialize()", function() {
// Add html5 elements only for serialize because selector can't yet find them on non-html5 browsers
jQuery("#search").after(
'<input type="email" id="html5email" name="email" value="dave@jquery.com" />'+
'<input type="number" id="html5number" name="number" value="43" />'
"<input type='email' id='html5email' name='email' value='dave@jquery.com' />"+
"<input type='number' id='html5number' name='number' value='43' />"
);
equals( jQuery('#form').serialize(),
equals( jQuery("#form").serialize(),
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3",
'Check form serialization as query string');
"Check form serialization as query string");
equals( jQuery('#form :input').serialize(),
equals( jQuery("#form :input").serialize(),
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3",
'Check input serialization as query string');
"Check input serialization as query string");
equals( jQuery('#testForm').serialize(),
'T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
'Check form serialization as query string');
equals( jQuery("#testForm").serialize(),
"T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
"Check form serialization as query string");
equals( jQuery('#testForm :input').serialize(),
'T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
'Check input serialization as query string');
equals( jQuery("#testForm :input").serialize(),
"T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
"Check input serialization as query string");
equals( jQuery('#form, #testForm').serialize(),
equals( jQuery("#form, #testForm").serialize(),
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3&T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
'Multiple form serialization as query string');
"Multiple form serialization as query string");
/* Temporarily disabled. Opera 10 has problems with form serialization.
equals( jQuery('#form, #testForm :input').serialize(),
equals( jQuery("#form, #testForm :input").serialize(),
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
'Mixed form/input serialization as query string');
"Mixed form/input serialization as query string");
*/
jQuery("#html5email, #html5number").remove();
});
@ -956,13 +956,13 @@ test("jQuery.param()", function() {
params = {someName: [1, 2, 3], regularThing: "blah" };
equals( jQuery.param(params), "someName%5B%5D=1&someName%5B%5D=2&someName%5B%5D=3&regularThing=blah", "with array" );
params = {foo: ['a', 'b', 'c']};
params = {foo: ["a", "b", "c"]};
equals( 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"] };
equals( 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" } };
equals( 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?" };
@ -974,7 +974,7 @@ 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?" };
equals( jQuery.param(params,true), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=undefined&l=0&m=cowboy+hat%3F", "huge structure, forced traditional" );
equals( 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." );
equals( 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." );
// Make sure empty arrays and objects are handled #6481
equals( jQuery.param({"foo": {"bar": []} }), "foo%5Bbar%5D=", "Empty array param" );
@ -992,7 +992,7 @@ test("jQuery.param()", function() {
params = {someName: [1, 2, 3], regularThing: "blah" };
equals( jQuery.param(params), "someName=1&someName=2&someName=3&regularThing=blah", "with array" );
params = {foo: ['a', 'b', 'c']};
params = {foo: ["a", "b", "c"]};
equals( jQuery.param(params), "foo=a&foo=b&foo=c", "with array of strings" );
params = {"foo[]":["baz", 42, "All your base are belong to us"]};
@ -1013,7 +1013,7 @@ test("jQuery.param()", function() {
params = { param1: null };
equals( jQuery.param(params,false), "param1=null", "Make sure that null params aren't traversed." );
params = {'test': {'length': 3, 'foo': 'bar'} };
params = {"test": {"length": 3, "foo": "bar"} };
equals( jQuery.param( params, false ), "test%5Blength%5D=3&test%5Bfoo%5D=bar", "Sub-object with a length property" );
});
@ -1044,10 +1044,10 @@ test("pass-through request object", function() {
errorCount++;
errorEx += ": " + xml.status;
});
jQuery("#foo").one('ajaxStop', function () {
jQuery("#foo").one("ajaxStop", function () {
equals(successCount, 5, "Check all ajax calls successful");
equals(errorCount, 0, "Check no ajax errors (status" + errorEx + ")");
jQuery("#foo").unbind('ajaxError');
jQuery("#foo").unbind("ajaxError");
start();
});
@ -1101,17 +1101,17 @@ test("global ajaxSettings", function() {
var orig = { url: "data/with_fries.xml" };
var t;
jQuery.ajaxSetup({ data: {foo: 'bar', bar: 'BAR'} });
jQuery.ajaxSetup({ data: {foo: "bar", bar: "BAR"} });
t = jQuery.extend({}, orig);
t.data = {};
jQuery.ajax(t);
ok( t.url.indexOf('foo') > -1 && t.url.indexOf('bar') > -1, "Check extending {}" );
ok( t.url.indexOf("foo") > -1 && t.url.indexOf("bar") > -1, "Check extending {}" );
t = jQuery.extend({}, orig);
t.data = { zoo: 'a', ping: 'b' };
t.data = { zoo: "a", ping: "b" };
jQuery.ajax(t);
ok( t.url.indexOf('ping') > -1 && t.url.indexOf('zoo') > -1 && t.url.indexOf('foo') > -1 && t.url.indexOf('bar') > -1, "Check extending { zoo: 'a', ping: 'b' }" );
ok( t.url.indexOf("ping") > -1 && t.url.indexOf("zoo") > -1 && t.url.indexOf("foo") > -1 && t.url.indexOf("bar") > -1, "Check extending { zoo: "a", ping: "b" }" );
jQuery.ajaxSettings = tmp;
});
@ -1120,13 +1120,13 @@ test("global ajaxSettings", function() {
test("load(String)", function() {
expect(1);
stop(); // check if load can be called with only url
jQuery('#first').load("data/name.html", start);
jQuery("#first").load("data/name.html", start);
});
test("load('url selector')", function() {
expect(1);
stop(); // check if load can be called with only url
jQuery('#first').load("data/test3.html div.user", function(){
jQuery("#first").load("data/test3.html div.user", function(){
equals( jQuery(this).children("div").length, 2, "Verify that specific elements were injected" );
start();
});
@ -1142,14 +1142,14 @@ test("load(String, Function) with ajaxSetup on dataType json, see #2046", functi
jQuery.ajaxSetup({ dataType: "" });
start();
});
jQuery('#first').load("data/test3.html");
jQuery("#first").load("data/test3.html");
});
test("load(String, Function) - simple: inject text into DOM", function() {
expect(2);
stop();
jQuery('#first').load(url("data/name.html"), function() {
ok( /^ERROR/.test(jQuery('#first').text()), 'Check if content was injected into the DOM' );
jQuery("#first").load(url("data/name.html"), function() {
ok( /^ERROR/.test(jQuery("#first").text()), "Check if content was injected into the DOM" );
start();
});
});
@ -1159,15 +1159,15 @@ test("load(String, Function) - check scripts", function() {
stop();
var verifyEvaluation = function() {
equals( foobar, "bar", 'Check if script src was evaluated after load' );
equals( jQuery('#ap').html(), 'bar', 'Check if script evaluation has modified DOM');
equals( foobar, "bar", "Check if script src was evaluated after load" );
equals( jQuery("#ap").html(), "bar", "Check if script evaluation has modified DOM");
start();
};
jQuery('#first').load(url('data/test.html'), function() {
ok( jQuery('#first').html().match(/^html text/), 'Check content after loading html' );
equals( jQuery('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
equals( testFoo, "foo", 'Check if script was evaluated after load' );
jQuery("#first").load(url("data/test.html"), function() {
ok( jQuery("#first").html().match(/^html text/), "Check content after loading html" );
equals( jQuery("#foo").html(), "foo", "Check if script evaluation has modified DOM");
equals( testFoo, "foo", "Check if script was evaluated after load" );
setTimeout(verifyEvaluation, 600);
});
});
@ -1176,9 +1176,9 @@ test("load(String, Function) - check file with only a script tag", function() {
expect(3);
stop();
jQuery('#first').load(url('data/test2.html'), function() {
equals( jQuery('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
equals( testFoo, "foo", 'Check if script was evaluated after load' );
jQuery("#first").load(url("data/test2.html"), function() {
equals( jQuery("#foo").html(), "foo", "Check if script evaluation has modified DOM");
equals( testFoo, "foo", "Check if script was evaluated after load" );
start();
});
@ -1200,10 +1200,10 @@ test("load(String, Object, Function)", function() {
expect(2);
stop();
jQuery('<div />').load(url('data/params_html.php'), { foo:3, bar:'ok' }, function() {
var $post = jQuery(this).find('#post');
equals( $post.find('#foo').text(), '3', 'Check if a hash of data is passed correctly');
equals( $post.find('#bar').text(), 'ok', 'Check if a hash of data is passed correctly');
jQuery("<div />").load(url("data/params_html.php"), { foo: 3, bar: "ok" }, function() {
var $post = jQuery(this).find("#post");
equals( $post.find("#foo").text(), "3", "Check if a hash of data is passed correctly");
equals( $post.find("#bar").text(), "ok", "Check if a hash of data is passed correctly");
start();
});
});
@ -1212,10 +1212,10 @@ test("load(String, String, Function)", function() {
expect(2);
stop();
jQuery('<div />').load(url('data/params_html.php'), 'foo=3&bar=ok', function() {
var $get = jQuery(this).find('#get');
equals( $get.find('#foo').text(), '3', 'Check if a string of data is passed correctly');
equals( $get.find('#bar').text(), 'ok', 'Check if a of data is passed correctly');
jQuery("<div />").load(url("data/params_html.php"), "foo=3&bar=ok", function() {
var $get = jQuery(this).find("#get");
equals( $get.find("#foo").text(), "3", "Check if a string of data is passed correctly");
equals( $get.find("#bar").text(), "ok", "Check if a of data is passed correctly");
start();
});
});
@ -1226,8 +1226,8 @@ test("jQuery.get(String, Function) - data in ajaxSettings (#8277)", function() {
jQuery.ajaxSetup({
data: "helloworld"
});
jQuery.get(url('data/echoQuery.php'), function(data) {
ok( /helloworld$/.test( data ), 'Data from ajaxSettings was used');
jQuery.get(url("data/echoQuery.php"), function(data) {
ok( /helloworld$/.test( data ), "Data from ajaxSettings was used");
jQuery.ajaxSetup({
data: null
});
@ -1238,13 +1238,13 @@ test("jQuery.get(String, Function) - data in ajaxSettings (#8277)", function() {
test("jQuery.get(String, Hash, Function) - parse xml and use text() on nodes", function() {
expect(2);
stop();
jQuery.get(url('data/dashboard.xml'), function(xml) {
jQuery.get(url("data/dashboard.xml"), function(xml) {
var content = [];
jQuery('tab', xml).each(function() {
jQuery("tab", xml).each(function() {
content.push(jQuery(this).text());
});
equals( content[0], 'blabla', 'Check first tab');
equals( content[1], 'blublu', 'Check second tab');
equals( content[0], "blabla", "Check first tab");
equals( content[1], "blublu", "Check second tab");
start();
});
});
@ -1253,7 +1253,7 @@ test("jQuery.getScript(String, Function) - with callback", function() {
expect(3);
stop();
jQuery.getScript(url("data/test.js"), function( data, _, jqXHR ) {
equals( foobar, "bar", 'Check if script was evaluated' );
equals( foobar, "bar", "Check if script was evaluated" );
strictEqual( data, jqXHR.responseText, "Same-domain script requests returns the source of the script (#8082)" );
setTimeout(start, 100);
});
@ -1636,10 +1636,10 @@ test("jQuery.ajax() - json by content-type", function() {
data: { header: "json", json: "array" },
success: function( json ) {
ok( json.length >= 2, "Check length");
equals( json[0].name, 'John', 'Check JSON: first, name' );
equals( json[0].age, 21, 'Check JSON: first, age' );
equals( json[1].name, 'Peter', 'Check JSON: second, name' );
equals( json[1].age, 25, 'Check JSON: second, age' );
equals( json[0].name, "John", "Check JSON: first, name" );
equals( json[0].age, 21, "Check JSON: first, age" );
equals( json[1].name, "Peter", "Check JSON: second, name" );
equals( json[1].age, 25, "Check JSON: second, age" );
start();
}
});
@ -1660,10 +1660,10 @@ test("jQuery.ajax() - json by content-type disabled with options", function() {
equals( typeof text , "string" , "json wasn't auto-determined" );
var json = jQuery.parseJSON( text );
ok( json.length >= 2, "Check length");
equals( json[0].name, 'John', 'Check JSON: first, name' );
equals( json[0].age, 21, 'Check JSON: first, age' );
equals( json[1].name, 'Peter', 'Check JSON: second, name' );
equals( json[1].age, 25, 'Check JSON: second, age' );
equals( json[0].name, "John", "Check JSON: first, name" );
equals( json[0].age, 21, "Check JSON: first, age" );
equals( json[1].name, "Peter", "Check JSON: second, name" );
equals( json[1].age, 25, "Check JSON: second, age" );
start();
}
});
@ -1674,10 +1674,10 @@ test("jQuery.getJSON(String, Hash, Function) - JSON array", function() {
stop();
jQuery.getJSON(url("data/json.php"), {json: "array"}, function(json) {
ok( json.length >= 2, "Check length");
equals( json[0].name, 'John', 'Check JSON: first, name' );
equals( json[0].age, 21, 'Check JSON: first, age' );
equals( json[1].name, 'Peter', 'Check JSON: second, name' );
equals( json[1].age, 25, 'Check JSON: second, age' );
equals( json[0].name, "John", "Check JSON: first, name" );
equals( json[0].age, 21, "Check JSON: first, age" );
equals( json[1].name, "Peter", "Check JSON: second, name" );
equals( json[1].age, 25, "Check JSON: second, age" );
start();
});
});
@ -1687,8 +1687,8 @@ test("jQuery.getJSON(String, Function) - JSON object", function() {
stop();
jQuery.getJSON(url("data/json.php"), function(json) {
if (json && json.data) {
equals( json.data.lang, 'en', 'Check JSON: lang' );
equals( json.data.length, 25, 'Check JSON: length' );
equals( json.data.lang, "en", "Check JSON: lang" );
equals( json.data.length, 25, "Check JSON: length" );
}
start();
});
@ -1720,8 +1720,8 @@ test("jQuery.getJSON(String, Function) - JSON object with absolute url to local
stop();
jQuery.getJSON(url(base + "data/json.php"), function(json) {
equals( json.data.lang, 'en', 'Check JSON: lang' );
equals( json.data.length, 25, 'Check JSON: length' );
equals( json.data.lang, "en", "Check JSON: lang" );
equals( json.data.length, 25, "Check JSON: length" );
start();
});
});
@ -1731,23 +1731,23 @@ test("jQuery.post - data", 3, function() {
jQuery.when(
jQuery.post( url( "data/name.php" ), { xml: "5-2", length: 3 }, function( xml ) {
jQuery( 'math', xml ).each( function() {
equals( jQuery( 'calculation', this ).text(), '5-2', 'Check for XML' );
equals( jQuery( 'result', this ).text(), '3', 'Check for XML' );
jQuery( "math", xml ).each( function() {
equals( jQuery( "calculation", this ).text(), "5-2", "Check for XML" );
equals( jQuery( "result", this ).text(), "3", "Check for XML" );
});
}),
jQuery.ajax({
url: url('data/echoData.php'),
url: url("data/echoData.php"),
type: "POST",
data: {
'test': {
'length': 7,
'foo': 'bar'
"test": {
"length": 7,
"foo": "bar"
}
},
success: function( data ) {
strictEqual( data, 'test%5Blength%5D=7&test%5Bfoo%5D=bar', 'Check if a sub-object with a length param is serialized correctly');
strictEqual( data, "test%5Blength%5D=7&test%5Bfoo%5D=bar", "Check if a sub-object with a length param is serialized correctly");
}
})
).then( start, start );
@ -1760,17 +1760,17 @@ test("jQuery.post(String, Hash, Function) - simple with xml", function() {
var done = 0;
jQuery.post(url("data/name.php"), {xml: "5-2"}, function(xml){
jQuery('math', xml).each(function() {
equals( jQuery('calculation', this).text(), '5-2', 'Check for XML' );
equals( jQuery('result', this).text(), '3', 'Check for XML' );
jQuery("math", xml).each(function() {
equals( jQuery("calculation", this).text(), "5-2", "Check for XML" );
equals( jQuery("result", this).text(), "3", "Check for XML" );
});
if ( ++done === 2 ) start();
});
jQuery.post(url("data/name.php?xml=5-2"), {}, function(xml){
jQuery('math', xml).each(function() {
equals( jQuery('calculation', this).text(), '5-2', 'Check for XML' );
equals( jQuery('result', this).text(), '3', 'Check for XML' );
jQuery("math", xml).each(function() {
equals( jQuery("calculation", this).text(), "5-2", "Check for XML" );
equals( jQuery("result", this).text(), "3", "Check for XML" );
});
if ( ++done === 2 ) start();
});
@ -1786,18 +1786,18 @@ test("jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() {
var pass = function() {
passed++;
if ( passed == 2 ) {
ok( true, 'Check local and global callbacks after timeout' );
jQuery('#main').unbind("ajaxError");
ok( true, "Check local and global callbacks after timeout" );
jQuery("#main").unbind("ajaxError");
start();
}
};
var fail = function(a,b,c) {
ok( false, 'Check for timeout failed ' + a + ' ' + b );
ok( false, "Check for timeout failed " + a + " " + b );
start();
};
jQuery('#main').ajaxError(pass);
jQuery("#main").ajaxError(pass);
jQuery.ajax({
type: "GET",
@ -1819,11 +1819,11 @@ test("jQuery.ajaxSetup({timeout: Number}) with localtimeout", function() {
timeout: 15000,
url: url("data/name.php?wait=1"),
error: function() {
ok( false, 'Check for local timeout failed' );
ok( false, "Check for local timeout failed" );
start();
},
success: function() {
ok( true, 'Check for local timeout' );
ok( true, "Check for local timeout" );
start();
}
});
@ -1839,7 +1839,7 @@ test("jQuery.ajax - simple get", function() {
type: "GET",
url: url("data/name.php?name=foo"),
success: function(msg){
equals( msg, 'bar', 'Check for GET' );
equals( msg, "bar", "Check for GET" );
start();
}
});
@ -1853,7 +1853,7 @@ test("jQuery.ajax - simple post", function() {
url: url("data/name.php"),
data: "name=peter",
success: function(msg){
equals( msg, 'pan', 'Check for POST' );
equals( msg, "pan", "Check for POST" );
start();
}
});
@ -1865,7 +1865,7 @@ test("ajaxSetup()", function() {
jQuery.ajaxSetup({
url: url("data/name.php?name=foo"),
success: function(msg){
equals( msg, 'bar', 'Check for GET' );
equals( msg, "bar", "Check for GET" );
start();
}
});
@ -2027,14 +2027,14 @@ test("jQuery ajax - failing cross-domain", function() {
var i = 2;
jQuery.ajax({
url: 'http://somewebsitethatdoesnotexist-67864863574657654.com',
url: "http://somewebsitethatdoesnotexist-67864863574657654.com",
success: function(){ ok( false , "success" ); },
error: function(xhr,_,e){ ok( true , "file not found: " + xhr.status + " => " + e ); },
complete: function() { if ( ! --i ) start(); }
});
jQuery.ajax({
url: 'http://www.google.com',
url: "http://www.google.com",
success: function(){ ok( false , "success" ); },
error: function(xhr,_,e){ ok( true , "access denied: " + xhr.status + " => " + e ); },
complete: function() { if ( ! --i ) start(); }
@ -2047,7 +2047,7 @@ test("jQuery ajax - atom+xml", function() {
stop();
jQuery.ajax({
url: url( 'data/atom+xml.php' ),
url: url( "data/atom+xml.php" ),
success: function(){ ok( true , "success" ); },
error: function(){ ok( false , "error" ); },
complete: function() { start(); }

View File

@ -37,19 +37,19 @@ test("jQuery.attrFix integrity test", function() {
test("prop(String, Object)", function() {
expect(19);
equals( jQuery('#text1').prop('value'), "Test", 'Check for value attribute' );
equals( jQuery('#text1').prop('value', "Test2").prop('defaultValue'), "Test", 'Check for defaultValue attribute' );
equals( jQuery('#select2').prop('selectedIndex'), 3, 'Check for selectedIndex attribute' );
equals( jQuery('#foo').prop('nodeName').toUpperCase(), 'DIV', 'Check for nodeName attribute' );
equals( jQuery('#foo').prop('tagName').toUpperCase(), 'DIV', 'Check for tagName attribute' );
equals( jQuery("#text1").prop("value"), "Test", "Check for value attribute" );
equals( jQuery("#text1").prop("value", "Test2").prop("defaultValue"), "Test", "Check for defaultValue attribute" );
equals( jQuery("#select2").prop("selectedIndex"), 3, "Check for selectedIndex attribute" );
equals( jQuery("#foo").prop("nodeName").toUpperCase(), "DIV", "Check for nodeName attribute" );
equals( jQuery("#foo").prop("tagName").toUpperCase(), "DIV", "Check for tagName attribute" );
equals( jQuery("<option/>").prop("selected"), false, "Check selected attribute on disconnected element." );
var body = document.body, $body = jQuery( body );
ok( $body.prop('nextSibling') === null, 'Make sure a null expando returns null' );
body.foo = 'bar';
equals( $body.prop('foo'), 'bar', 'Make sure the expando is preferred over the dom attribute' );
ok( $body.prop("nextSibling") === null, "Make sure a null expando returns null" );
body.foo = "bar";
equals( $body.prop("foo"), "bar", "Make sure the expando is preferred over the dom attribute" );
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");
optgroup.appendChild( option );
@ -78,62 +78,62 @@ test("prop(String, Object)", function() {
test("attr(String)", function() {
expect(32);
equals( jQuery('#text1').attr('type'), "text", 'Check for type attribute' );
equals( jQuery('#radio1').attr('type'), "radio", 'Check for type attribute' );
equals( jQuery('#check1').attr('type'), "checkbox", 'Check for type attribute' );
equals( jQuery('#simon1').attr('rel'), "bookmark", 'Check for rel attribute' );
equals( jQuery('#google').attr('title'), "Google!", 'Check for title attribute' );
equals( jQuery('#mark').attr('hreflang'), "en", 'Check for hreflang attribute' );
equals( jQuery('#en').attr('lang'), "en", 'Check for lang attribute' );
equals( jQuery('#simon').attr('class'), "blog link", 'Check for class attribute' );
equals( jQuery('#name').attr('name'), "name", 'Check for name attribute' );
equals( jQuery('#text1').attr('name'), "action", 'Check for name attribute' );
ok( jQuery('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' );
equals( jQuery('#form').attr('blah', 'blah').attr('blah'), 'blah', 'Set non-existant attribute on a form' );
equals( jQuery('#foo').attr('height'), undefined, 'Non existent height attribute should return undefined' );
equals( jQuery("#text1").attr("type"), "text", "Check for type attribute" );
equals( jQuery("#radio1").attr("type"), "radio", "Check for type attribute" );
equals( jQuery("#check1").attr("type"), "checkbox", "Check for type attribute" );
equals( jQuery("#simon1").attr("rel"), "bookmark", "Check for rel attribute" );
equals( jQuery("#google").attr("title"), "Google!", "Check for title attribute" );
equals( jQuery("#mark").attr("hreflang"), "en", "Check for hreflang attribute" );
equals( jQuery("#en").attr("lang"), "en", "Check for lang attribute" );
equals( jQuery("#simon").attr("class"), "blog link", "Check for class attribute" );
equals( jQuery("#name").attr("name"), "name", "Check for name attribute" );
equals( jQuery("#text1").attr("name"), "action", "Check for name attribute" );
ok( jQuery("#form").attr("action").indexOf("formaction") >= 0, "Check for action attribute" );
equals( jQuery("#form").attr("blah", "blah").attr("blah"), "blah", "Set non-existant attribute on a form" );
equals( jQuery("#foo").attr("height"), undefined, "Non existent height attribute should return undefined" );
// [7472] & [3113] (form contains an input with name="action" or name="id")
var extras = jQuery('<input name="id" name="name" /><input id="target" name="target" />').appendTo('#testForm');
equals( jQuery('#form').attr('action','newformaction').attr('action'), 'newformaction', 'Check that action attribute was changed' );
equals( jQuery('#testForm').attr('target'), undefined, 'Retrieving target does not equal the input with name=target' );
equals( jQuery('#testForm').attr('target', 'newTarget').attr('target'), 'newTarget', 'Set target successfully on a form' );
equals( jQuery('#testForm').removeAttr('id').attr('id'), undefined, 'Retrieving id does not equal the input with name=id after id is removed [#7472]' );
var extras = jQuery("<input name='id' name='name' /><input id='target' name='target' />").appendTo("#testForm");
equals( jQuery("#form").attr("action","newformaction").attr("action"), "newformaction", "Check that action attribute was changed" );
equals( jQuery("#testForm").attr("target"), undefined, "Retrieving target does not equal the input with name=target" );
equals( jQuery("#testForm").attr("target", "newTarget").attr("target"), "newTarget", "Set target successfully on a form" );
equals( jQuery("#testForm").removeAttr("id").attr("id"), undefined, "Retrieving id does not equal the input with name=id after id is removed [#7472]" );
// Bug #3685 (form contains input with name="name")
equals( jQuery('#testForm').attr('name'), undefined, 'Retrieving name does not retrieve input with name=name' );
equals( jQuery("#testForm").attr("name"), undefined, "Retrieving name does not retrieve input with name=name" );
extras.remove();
equals( jQuery('#text1').attr('maxlength'), '30', 'Check for maxlength attribute' );
equals( jQuery('#text1').attr('maxLength'), '30', 'Check for maxLength attribute' );
equals( jQuery('#area1').attr('maxLength'), '30', 'Check for maxLength attribute' );
equals( jQuery("#text1").attr("maxlength"), "30", "Check for maxlength attribute" );
equals( jQuery("#text1").attr("maxLength"), "30", "Check for maxLength attribute" );
equals( jQuery("#area1").attr("maxLength"), "30", "Check for maxLength attribute" );
// using innerHTML in IE causes href attribute to be serialized to the full path
jQuery('<a/>').attr({ 'id': 'tAnchor5', 'href': '#5' }).appendTo('#main');
equals( jQuery('#tAnchor5').attr('href'), "#5", 'Check for non-absolute href (an anchor)' );
jQuery("<a/>").attr({ "id": "tAnchor5", "href": "#5" }).appendTo("#main");
equals( jQuery("#tAnchor5").attr("href"), "#5", "Check for non-absolute href (an anchor)" );
// list attribute is readonly by default in browsers that support it
jQuery('#list-test').attr('list', 'datalist');
equals( jQuery('#list-test').attr('list'), 'datalist', 'Check setting list attribute' );
jQuery("#list-test").attr("list", "datalist");
equals( jQuery("#list-test").attr("list"), "datalist", "Check setting list attribute" );
// Related to [5574] and [5683]
var body = document.body, $body = jQuery(body);
strictEqual( $body.attr('foo'), undefined, 'Make sure that a non existent attribute returns undefined' );
strictEqual( $body.attr("foo"), undefined, "Make sure that a non existent attribute returns undefined" );
body.setAttribute('foo', 'baz');
equals( $body.attr('foo'), 'baz', 'Make sure the dom attribute is retrieved when no expando is found' );
body.setAttribute("foo", "baz");
equals( $body.attr("foo"), "baz", "Make sure the dom attribute is retrieved when no expando is found" );
$body.attr('foo','cool');
equals( $body.attr('foo'), 'cool', 'Make sure that setting works well when both expando and dom attribute are available' );
$body.attr("foo","cool");
equals( $body.attr("foo"), "cool", "Make sure that setting works well when both expando and dom attribute are available" );
body.removeAttribute('foo'); // Cleanup
body.removeAttribute("foo"); // Cleanup
var $img = jQuery('<img style="display:none" width="215" height="53" src="http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif"/>').appendTo('body');
equals( $img.attr('width'), "215", "Retrieve width attribute an an element with display:none." );
equals( $img.attr('height'), "53", "Retrieve height attribute an an element with display:none." );
var $img = jQuery("<img style='display:none' width='215' height='53' src='http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif'/>").appendTo("body");
equals( $img.attr("width"), "215", "Retrieve width attribute an an element with display:none." );
equals( $img.attr("height"), "53", "Retrieve height attribute an an element with display:none." );
// Check for style support
ok( !!~jQuery('#dl').attr('style').indexOf('position'), 'Check style attribute getter, also normalize css props to lowercase' );
ok( !!~jQuery('#foo').attr('style', 'position:absolute;').attr('style').indexOf('position'), 'Check style setter' );
ok( !!~jQuery("#dl").attr("style").indexOf("position"), "Check style attribute getter, also normalize css props to lowercase" );
ok( !!~jQuery("#foo").attr("style", "position:absolute;").attr("style").indexOf("position"), "Check style setter" );
ok( jQuery("<div/>").attr("doesntexist") === undefined, "Make sure undefined is returned when no attribute is found." );
ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." );
@ -153,19 +153,19 @@ if ( !isLocal ) {
test("attr(String, Function)", function() {
expect(2);
equals( jQuery('#text1').attr('value', function() { return this.id; })[0].value, "text1", "Set value from id" );
equals( jQuery('#text1').attr('title', function(i) { return i; }).attr('title'), "0", "Set value with an index");
equals( jQuery("#text1").attr("value", function() { return this.id; })[0].value, "text1", "Set value from id" );
equals( jQuery("#text1").attr("title", function(i) { return i; }).attr("title"), "0", "Set value with an index");
});
test("attr(Hash)", function() {
expect(3);
var pass = true;
jQuery("div").attr({foo: 'baz', zoo: 'ping'}).each(function(){
if ( this.getAttribute('foo') != "baz" && this.getAttribute('zoo') != "ping" ) pass = false;
jQuery("div").attr({foo: "baz", zoo: "ping"}).each(function(){
if ( this.getAttribute("foo") != "baz" && this.getAttribute("zoo") != "ping" ) pass = false;
});
ok( pass, "Set Multiple Attributes" );
equals( jQuery('#text1').attr({'value': function() { return this.id; }})[0].value, "text1", "Set attribute to computed value #1" );
equals( jQuery('#text1').attr({'title': function(i) { return i; }}).attr('title'), "0", "Set attribute to computed value #2");
equals( jQuery("#text1").attr({value: function() { return this.id; }})[0].value, "text1", "Set attribute to computed value #1" );
equals( jQuery("#text1").attr({title: function(i) { return i; }}).attr("title"), "0", "Set attribute to computed value #2");
});
@ -176,7 +176,7 @@ test("attr(String, Object)", function() {
fail = false;
for ( var i = 0; i < div.size(); i++ ) {
if ( div.get(i).getAttribute('foo') != "bar" ){
if ( div.get(i).getAttribute("foo") != "bar" ){
fail = i;
break;
}
@ -187,25 +187,25 @@ test("attr(String, Object)", function() {
// Fails on IE since recent changes to .attr()
// ok( jQuery("#foo").attr({"width": null}), "Try to set an attribute to nothing" );
jQuery("#name").attr('name', 'something');
equals( jQuery("#name").attr('name'), 'something', 'Set name attribute' );
jQuery("#name").attr('name', null);
equals( jQuery("#name").attr('name'), undefined, 'Remove name attribute' );
jQuery("#check2").attr('checked', true);
equals( document.getElementById('check2').checked, true, 'Set checked attribute' );
jQuery("#check2").attr('checked', false);
equals( document.getElementById('check2').checked, false, 'Set checked attribute' );
jQuery("#text1").attr('readonly', true);
equals( document.getElementById('text1').readOnly, true, 'Set readonly attribute' );
jQuery("#text1").attr('readonly', false);
equals( document.getElementById('text1').readOnly, false, 'Set readonly attribute' );
jQuery("#name").attr('maxlength', '5');
equals( document.getElementById('name').maxLength, 5, 'Set maxlength attribute' );
jQuery("#name").attr('maxLength', '10');
equals( document.getElementById('name').maxLength, 10, 'Set maxlength attribute' );
var $p = jQuery('#firstp').attr('nonexisting', 'foo');
equals( $p.attr('nonexisting'), 'foo', "attr(name, value) works correctly for non existing attributes (bug #7500).");
$p.removeAttr('nonexisting');
jQuery("#name").attr("name", "something");
equals( jQuery("#name").attr("name"), "something", "Set name attribute" );
jQuery("#name").attr("name", null);
equals( jQuery("#name").attr("name"), undefined, "Remove name attribute" );
jQuery("#check2").attr("checked", true);
equals( document.getElementById("check2").checked, true, "Set checked attribute" );
jQuery("#check2").attr("checked", false);
equals( document.getElementById("check2").checked, false, "Set checked attribute" );
jQuery("#text1").attr("readonly", true);
equals( document.getElementById("text1").readOnly, true, "Set readonly attribute" );
jQuery("#text1").attr("readonly", false);
equals( document.getElementById("text1").readOnly, false, "Set readonly attribute" );
jQuery("#name").attr("maxlength", "5");
equals( document.getElementById("name").maxLength, 5, "Set maxlength attribute" );
jQuery("#name").attr("maxLength", "10");
equals( document.getElementById("name").maxLength, 10, "Set maxlength attribute" );
var $p = jQuery("#firstp").attr("nonexisting", "foo");
equals( $p.attr("nonexisting"), "foo", "attr(name, value) works correctly for non existing attributes (bug #7500).");
$p.removeAttr("nonexisting");
var attributeNode = document.createAttribute("irrelevant"),
commentNode = document.createComment("some comment"),
@ -217,8 +217,8 @@ test("attr(String, Object)", function() {
strictEqual( $ele.attr("nonexisting"), undefined, "attr(name, value) works correctly on comment and text nodes (bug #7500)." );
});
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');
var table = jQuery("#table").append("<tr><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr>"),
td = table.find("td:first");
td.attr("rowspan", "2");
equals( td[0].rowSpan, 2, "Check rowspan is correctly set" );
td.attr("colspan", "2");
@ -227,12 +227,12 @@ test("attr(String, Object)", function() {
equals( table[0].cellSpacing, "2", "Check cellspacing is correctly set" );
// for #1070
jQuery("#name").attr('someAttr', '0');
equals( jQuery("#name").attr('someAttr'), '0', 'Set attribute to a string of "0"' );
jQuery("#name").attr('someAttr', 0);
equals( jQuery("#name").attr('someAttr'), '0', 'Set attribute to the number 0' );
jQuery("#name").attr('someAttr', 1);
equals( jQuery("#name").attr('someAttr'), '1', 'Set attribute to the number 1' );
jQuery("#name").attr("someAttr", "0");
equals( jQuery("#name").attr("someAttr"), "0", "Set attribute to a string of \"0\"" );
jQuery("#name").attr("someAttr", 0);
equals( jQuery("#name").attr("someAttr"), "0", "Set attribute to the number 0" );
jQuery("#name").attr("someAttr", 1);
equals( jQuery("#name").attr("someAttr"), "1", "Set attribute to the number 1" );
// using contents will get comments regular, text, and comment nodes
var j = jQuery("#nonnodes").contents();
@ -244,51 +244,51 @@ test("attr(String, Object)", function() {
QUnit.reset();
// Type
var type = jQuery("#check2").attr('type');
var type = jQuery("#check2").attr("type");
var thrown = false;
try {
jQuery("#check2").attr('type','hidden');
jQuery("#check2").attr("type","hidden");
} catch(e) {
thrown = true;
}
ok( thrown, "Exception thrown when trying to change type property" );
equals( type, jQuery("#check2").attr('type'), "Verify that you can't change the type of an input element" );
equals( type, jQuery("#check2").attr("type"), "Verify that you can't change the type of an input element" );
var check = document.createElement("input");
var thrown = true;
try {
jQuery(check).attr('type','checkbox');
jQuery(check).attr("type", "checkbox");
} catch(e) {
thrown = false;
}
ok( thrown, "Exception thrown when trying to change type property" );
equals( "checkbox", jQuery(check).attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" );
equals( "checkbox", jQuery(check).attr("type"), "Verify that you can change the type of an input element that isn't in the DOM" );
var check = jQuery("<input />");
var thrown = true;
try {
check.attr('type','checkbox');
check.attr("type","checkbox");
} catch(e) {
thrown = false;
}
ok( thrown, "Exception thrown when trying to change type property" );
equals( "checkbox", check.attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" );
equals( "checkbox", check.attr("type"), "Verify that you can change the type of an input element that isn't in the DOM" );
var button = jQuery("#button");
var thrown = false;
try {
button.attr('type','submit');
button.attr("type","submit");
} catch(e) {
thrown = true;
}
ok( thrown, "Exception thrown when trying to change type property" );
equals( "button", button.attr('type'), "Verify that you can't change the type of a button element" );
equals( "button", button.attr("type"), "Verify that you can't change the type of a button element" );
// Setting attributes on svg elements (bug #3116)
var $svg = jQuery('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="3000" height="3000">'
+ '<circle cx="200" cy="200" r="150" />'
+ '</svg>').appendTo('body');
equals( $svg.attr('cx', 100).attr('cx'), "100", "Set attribute on svg element" );
var $svg = jQuery("<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' baseProfile='full' width='3000' height='3000'>"
+ "<circle cx='200' cy='200' r='150' />"
+ "</svg>").appendTo("body");
equals( $svg.attr("cx", 100).attr("cx"), "100", "Set attribute on svg element" );
$svg.remove();
});
@ -299,17 +299,17 @@ test("attr(jquery_method)", function(){
elem = $elem[0];
// one at a time
$elem.attr({'html': 'foo'}, true);
equals( elem.innerHTML, 'foo', 'attr(html)');
$elem.attr({html: "foo"}, true);
equals( elem.innerHTML, "foo", "attr(html)");
$elem.attr({'text': 'bar'}, true);
equals( elem.innerHTML, 'bar', 'attr(text)');
$elem.attr({text: "bar"}, true);
equals( elem.innerHTML, "bar", "attr(text)");
$elem.attr({'css': {color:'red'}}, true);
ok( /^(#ff0000|red)$/i.test(elem.style.color), 'attr(css)');
$elem.attr({css: {color: "red"}}, true);
ok( /^(#ff0000|red)$/i.test(elem.style.color), "attr(css)");
$elem.attr({'height': 10}, true);
equals( elem.style.height, '10px', 'attr(height)');
$elem.attr({height: 10}, true);
equals( elem.style.height, "10px", "attr(height)");
// Multiple attributes
@ -318,22 +318,22 @@ test("attr(jquery_method)", function(){
css:{ paddingLeft:1, paddingRight:1 }
}, true);
equals( elem.style.width, '10px', 'attr({...})');
equals( elem.style.paddingLeft, '1px', 'attr({...})');
equals( elem.style.paddingRight, '1px', 'attr({...})');
equals( elem.style.width, "10px", "attr({...})");
equals( elem.style.paddingLeft, "1px", "attr({...})");
equals( elem.style.paddingRight, "1px", "attr({...})");
});
if ( !isLocal ) {
test("attr(String, Object) - Loaded via XML document", function() {
expect(2);
stop();
jQuery.get('data/dashboard.xml', function(xml) {
jQuery.get("data/dashboard.xml", function(xml) {
var titles = [];
jQuery('tab', xml).each(function() {
titles.push(jQuery(this).attr('title'));
jQuery("tab", xml).each(function() {
titles.push(jQuery(this).attr("title"));
});
equals( titles[0], 'Location', 'attr() in XML context: Check first title' );
equals( titles[1], 'Users', 'attr() in XML context: Check second title' );
equals( titles[0], "Location", "attr() in XML context: Check first title" );
equals( titles[1], "Users", "attr() in XML context: Check second title" );
start();
});
});
@ -343,64 +343,64 @@ test("attr('tabindex')", function() {
expect(8);
// elements not natively tabbable
equals(jQuery('#listWithTabIndex').attr('tabindex'), 5, 'not natively tabbable, with tabindex set to 0');
equals(jQuery('#divWithNoTabIndex').attr('tabindex'), undefined, 'not natively tabbable, no tabindex set');
equals(jQuery("#listWithTabIndex").attr("tabindex"), 5, "not natively tabbable, with tabindex set to 0");
equals(jQuery("#divWithNoTabIndex").attr("tabindex"), undefined, "not natively tabbable, no tabindex set");
// anchor with href
equals(jQuery('#linkWithNoTabIndex').attr('tabindex'), 0, 'anchor with href, no tabindex set');
equals(jQuery('#linkWithTabIndex').attr('tabindex'), 2, 'anchor with href, tabindex set to 2');
equals(jQuery('#linkWithNegativeTabIndex').attr('tabindex'), -1, 'anchor with href, tabindex set to -1');
equals(jQuery("#linkWithNoTabIndex").attr("tabindex"), 0, "anchor with href, no tabindex set");
equals(jQuery("#linkWithTabIndex").attr("tabindex"), 2, "anchor with href, tabindex set to 2");
equals(jQuery("#linkWithNegativeTabIndex").attr("tabindex"), -1, "anchor with href, tabindex set to -1");
// anchor without href
equals(jQuery('#linkWithNoHrefWithNoTabIndex').attr('tabindex'), undefined, 'anchor without href, no tabindex set');
equals(jQuery('#linkWithNoHrefWithTabIndex').attr('tabindex'), 1, 'anchor without href, tabindex set to 2');
equals(jQuery('#linkWithNoHrefWithNegativeTabIndex').attr('tabindex'), -1, 'anchor without href, no tabindex set');
equals(jQuery("#linkWithNoHrefWithNoTabIndex").attr("tabindex"), undefined, "anchor without href, no tabindex set");
equals(jQuery("#linkWithNoHrefWithTabIndex").attr("tabindex"), 1, "anchor without href, tabindex set to 2");
equals(jQuery("#linkWithNoHrefWithNegativeTabIndex").attr("tabindex"), -1, "anchor without href, no tabindex set");
});
test("attr('tabindex', value)", function() {
expect(9);
var element = jQuery('#divWithNoTabIndex');
equals(element.attr('tabindex'), undefined, 'start with no tabindex');
var element = jQuery("#divWithNoTabIndex");
equals(element.attr("tabindex"), undefined, "start with no tabindex");
// set a positive string
element.attr('tabindex', '1');
equals(element.attr('tabindex'), 1, 'set tabindex to 1 (string)');
element.attr("tabindex", "1");
equals(element.attr("tabindex"), 1, "set tabindex to 1 (string)");
// set a zero string
element.attr('tabindex', '0');
equals(element.attr('tabindex'), 0, 'set tabindex to 0 (string)');
element.attr("tabindex", "0");
equals(element.attr("tabindex"), 0, "set tabindex to 0 (string)");
// set a negative string
element.attr('tabindex', '-1');
equals(element.attr('tabindex'), -1, 'set tabindex to -1 (string)');
element.attr("tabindex", "-1");
equals(element.attr("tabindex"), -1, "set tabindex to -1 (string)");
// set a positive number
element.attr('tabindex', 1);
equals(element.attr('tabindex'), 1, 'set tabindex to 1 (number)');
element.attr("tabindex", 1);
equals(element.attr("tabindex"), 1, "set tabindex to 1 (number)");
// set a zero number
element.attr('tabindex', 0);
equals(element.attr('tabindex'), 0, 'set tabindex to 0 (number)');
element.attr("tabindex", 0);
equals(element.attr("tabindex"), 0, "set tabindex to 0 (number)");
// set a negative number
element.attr('tabindex', -1);
equals(element.attr('tabindex'), -1, 'set tabindex to -1 (number)');
element.attr("tabindex", -1);
equals(element.attr("tabindex"), -1, "set tabindex to -1 (number)");
element = jQuery('#linkWithTabIndex');
equals(element.attr('tabindex'), 2, 'start with tabindex 2');
element = jQuery("#linkWithTabIndex");
equals(element.attr("tabindex"), 2, "start with tabindex 2");
element.attr('tabindex', -1);
equals(element.attr('tabindex'), -1, 'set negative tabindex');
element.attr("tabindex", -1);
equals(element.attr("tabindex"), -1, "set negative tabindex");
});
test("removeAttr(String)", function() {
expect(5);
equals( jQuery('#mark').removeAttr( "class" )[0].className, "", "remove class" );
equals( jQuery('#form').removeAttr('id').attr('id'), undefined, 'Remove id' );
equals( jQuery('#foo').attr('style', 'position:absolute;').removeAttr('style').attr('style'), undefined, 'Check removing style attribute' );
equals( jQuery('#form').attr('style', 'position:absolute;').removeAttr('style').attr('style'), undefined, 'Check removing style attribute on a form' );
equals( jQuery('#fx-test-group').attr('height', '3px').removeAttr('height').css('height'), "1px", 'Removing height attribute has no effect on height set with style attribute' );
equals( jQuery("#mark").removeAttr( "class" )[0].className, "", "remove class" );
equals( jQuery("#form").removeAttr("id").attr("id"), undefined, "Remove id" );
equals( jQuery("#foo").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute" );
equals( jQuery("#form").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute on a form" );
equals( jQuery("#fx-test-group").attr("height", "3px").removeAttr("height").css("height"), "1px", "Removing height attribute has no effect on height set with style attribute" );
});
test("removeProp(String)", function() {
@ -427,7 +427,7 @@ test("removeProp(String)", function() {
test("val()", function() {
expect(23);
document.getElementById('text1').value = "bla";
document.getElementById("text1").value = "bla";
equals( jQuery("#text1").val(), "bla", "Check for modified value of input element" );
QUnit.reset();
@ -437,36 +437,36 @@ test("val()", function() {
equals( jQuery("#first").val(), "", "Check a paragraph element to see if it has a value" );
ok( jQuery([]).val() === undefined, "Check an empty jQuery object will return undefined from val" );
equals( jQuery('#select2').val(), '3', 'Call val() on a single="single" select' );
equals( jQuery("#select2").val(), "3", "Call val() on a single=\"single\" select" );
same( jQuery('#select3').val(), ['1', '2'], 'Call val() on a multiple="multiple" select' );
same( jQuery("#select3").val(), ["1", "2"], "Call val() on a multiple=\"multiple\" select" );
equals( jQuery('#option3c').val(), '2', 'Call val() on a option element with value' );
equals( jQuery("#option3c").val(), "2", "Call val() on a option element with value" );
equals( jQuery('#option3a').val(), '', 'Call val() on a option element with empty value' );
equals( jQuery("#option3a").val(), "", "Call val() on a option element with empty value" );
equals( jQuery('#option3e').val(), 'no value', 'Call val() on a option element with no value attribute' );
equals( jQuery("#option3e").val(), "no value", "Call val() on a option element with no value attribute" );
equals( jQuery('#option3a').val(), '', 'Call val() on a option element with no value attribute' );
equals( jQuery("#option3a").val(), "", "Call val() on a option element with no value attribute" );
jQuery('#select3').val("");
same( jQuery('#select3').val(), [''], 'Call val() on a multiple="multiple" select' );
jQuery("#select3").val("");
same( jQuery("#select3").val(), [""], "Call val() on a multiple=\"multiple\" select" );
same( jQuery('#select4').val(), [], 'Call val() on multiple="multiple" select with all disabled options' );
same( jQuery("#select4").val(), [], "Call val() on multiple=\"multiple\" select with all disabled options" );
jQuery('#select4 optgroup').add('#select4 > [disabled]').attr('disabled', false);
same( jQuery('#select4').val(), ['2', '3'], 'Call val() on multiple="multiple" select with some disabled options' );
jQuery("#select4 optgroup").add("#select4 > [disabled]").attr("disabled", false);
same( jQuery("#select4").val(), ["2", "3"], "Call val() on multiple=\"multiple\" select with some disabled options" );
jQuery('#select4').attr('disabled', true);
same( jQuery('#select4').val(), ['2', '3'], 'Call val() on disabled multiple="multiple" select' );
jQuery("#select4").attr("disabled", true);
same( jQuery("#select4").val(), ["2", "3"], "Call val() on disabled multiple=\"multiple\" select" );
equals( jQuery('#select5').val(), "3", "Check value on ambiguous select." );
equals( jQuery("#select5").val(), "3", "Check value on ambiguous select." );
jQuery('#select5').val(1);
equals( jQuery('#select5').val(), "1", "Check value on ambiguous select." );
jQuery("#select5").val(1);
equals( jQuery("#select5").val(), "1", "Check value on ambiguous select." );
jQuery('#select5').val(3);
equals( jQuery('#select5').val(), "3", "Check value on ambiguous select." );
jQuery("#select5").val(3);
equals( jQuery("#select5").val(), "3", "Check value on ambiguous select." );
var checks = jQuery("<input type='checkbox' name='test' value='1'/><input type='checkbox' name='test' value='2'/><input type='checkbox' name='test' value=''/><input type='checkbox' name='test'/>").appendTo("#form");
@ -492,17 +492,17 @@ test("val()", function() {
var testVal = function(valueObj) {
expect(8);
jQuery("#text1").val(valueObj( 'test' ));
equals( document.getElementById('text1').value, "test", "Check for modified (via val(String)) value of input element" );
jQuery("#text1").val(valueObj( "test" ));
equals( document.getElementById("text1").value, "test", "Check for modified (via val(String)) value of input element" );
jQuery("#text1").val(valueObj( undefined ));
equals( document.getElementById('text1').value, "", "Check for modified (via val(undefined)) value of input element" );
equals( document.getElementById("text1").value, "", "Check for modified (via val(undefined)) value of input element" );
jQuery("#text1").val(valueObj( 67 ));
equals( document.getElementById('text1').value, "67", "Check for modified (via val(Number)) value of input element" );
equals( document.getElementById("text1").value, "67", "Check for modified (via val(Number)) value of input element" );
jQuery("#text1").val(valueObj( null ));
equals( document.getElementById('text1').value, "", "Check for modified (via val(null)) value of input element" );
equals( document.getElementById("text1").value, "", "Check for modified (via val(null)) value of input element" );
jQuery("#select1").val(valueObj( "3" ));
equals( jQuery("#select1").val(), "3", "Check for modified (via val(String)) value of select element" );
@ -531,8 +531,8 @@ test("val(Function)", function() {
test( "val(Array of Numbers) (Bug #7123)", function() {
expect(4);
jQuery('#form').append('<input type="checkbox" name="arrayTest" value="1" /><input type="checkbox" name="arrayTest" value="2" /><input type="checkbox" name="arrayTest" value="3" checked="checked" /><input type="checkbox" name="arrayTest" value="4" />');
var elements = jQuery('input[name=arrayTest]').val([ 1, 2 ]);
jQuery("#form").append("<input type='checkbox' name='arrayTest' value='1' /><input type='checkbox' name='arrayTest' value='2' /><input type='checkbox' name='arrayTest' value='3' checked='checked' /><input type='checkbox' name='arrayTest' value='4' />");
var elements = jQuery("input[name=arrayTest]").val([ 1, 2 ]);
ok( elements[0].checked, "First element was checked" );
ok( elements[1].checked, "Second element was checked" );
ok( !elements[2].checked, "Third element was unchecked" );
@ -551,7 +551,7 @@ test("val(Function) with incoming value", function() {
return "test";
});
equals( document.getElementById('text1').value, "test", "Check for modified (via val(String)) value of input element" );
equals( document.getElementById("text1").value, "test", "Check for modified (via val(String)) value of input element" );
oldVal = jQuery("#text1").val();
@ -560,7 +560,7 @@ test("val(Function) with incoming value", function() {
return 67;
});
equals( document.getElementById('text1').value, "67", "Check for modified (via val(Number)) value of input element" );
equals( document.getElementById("text1").value, "67", "Check for modified (via val(Number)) value of input element" );
oldVal = jQuery("#select1").val();
@ -596,7 +596,7 @@ test("val(Function) with incoming value", function() {
test("val(select) after form.reset() (Bug #2551)", function() {
expect(3);
jQuery('<form id="kk" name="kk"><select id="kkk"><option value="cf">cf</option><option value="gf">gf</option></select></form>').appendTo("#main");
jQuery("<form id='kk' name='kk'><select id='kkk'><option value='cf'>cf</option><option value='gf'>gf</option></select></form>").appendTo("#main");
jQuery("#kkk").val( "gf" );
@ -606,7 +606,7 @@ test("val(select) after form.reset() (Bug #2551)", function() {
equal( jQuery("#kkk").val(), "cf", "Check value of select after form reset." );
// re-verify the multi-select is not broken (after form.reset) by our fix for single-select
same( jQuery('#select3').val(), ['1', '2'], 'Call val() on a multiple="multiple" select' );
same( jQuery("#select3").val(), ["1", "2"], "Call val() on a multiple=\"multiple\" select" );
jQuery("#kk").remove();
});
@ -671,29 +671,29 @@ test("addClass(Function) with incoming value", function() {
var testRemoveClass = function(valueObj) {
expect(7);
var $divs = jQuery('div');
var $divs = jQuery("div");
$divs.addClass("test").removeClass( valueObj("test") );
ok( !$divs.is('.test'), "Remove Class" );
ok( !$divs.is(".test"), "Remove Class" );
QUnit.reset();
$divs = jQuery('div');
$divs = jQuery("div");
$divs.addClass("test").addClass("foo").addClass("bar");
$divs.removeClass( valueObj("test") ).removeClass( valueObj("bar") ).removeClass( valueObj("foo") );
ok( !$divs.is('.test,.bar,.foo'), "Remove multiple classes" );
ok( !$divs.is(".test,.bar,.foo"), "Remove multiple classes" );
QUnit.reset();
$divs = jQuery('div');
$divs = jQuery("div");
// Make sure that a null value doesn't cause problems
$divs.eq(0).addClass("test").removeClass( valueObj(null) );
ok( $divs.eq(0).is('.test'), "Null value passed to removeClass" );
ok( $divs.eq(0).is(".test"), "Null value passed to removeClass" );
$divs.eq(0).addClass("test").removeClass( valueObj("") );
ok( $divs.eq(0).is('.test'), "Empty string passed to removeClass" );
ok( $divs.eq(0).is(".test"), "Empty string passed to removeClass" );
// using contents will get regular, text, and comment nodes
var j = jQuery("#nonnodes").contents();
@ -723,7 +723,7 @@ test("removeClass(Function) - simple", function() {
test("removeClass(Function) with incoming value", function() {
expect(45);
var $divs = jQuery('div').addClass("test"), old = $divs.map(function(){
var $divs = jQuery("div").addClass("test"), old = $divs.map(function(){
return jQuery(this).attr("class");
});
@ -734,7 +734,7 @@ test("removeClass(Function) with incoming value", function() {
}
});
ok( !$divs.is('.test'), "Remove Class" );
ok( !$divs.is(".test"), "Remove Class" );
QUnit.reset();
});
@ -772,7 +772,7 @@ var testToggleClass = function(valueObj) {
ok( e.is(".testD.testE"), "Assert class present" );
e.toggleClass();
ok( !e.is(".testD.testE"), "Assert class not present" );
ok( jQuery._data(e[0], '__className__') === 'testD testE', "Assert data was stored" );
ok( jQuery._data(e[0], "__className__") === "testD testE", "Assert data was stored" );
e.toggleClass();
ok( e.is(".testD.testE"), "Assert class present (restored from data)" );
e.toggleClass(false);
@ -786,7 +786,7 @@ var testToggleClass = function(valueObj) {
// Cleanup
e.removeClass("testD");
jQuery.removeData(e[0], '__className__', true);
jQuery.removeData(e[0], "__className__", true);
};
test("toggleClass(String|boolean|undefined[, boolean])", function() {
@ -847,7 +847,7 @@ test("toggleClass(Fucntion[, boolean]) with incoming value", function() {
// Cleanup
e.removeClass("test");
jQuery.removeData(e[0], '__className__', true);
jQuery.removeData(e[0], "__className__", true);
});
test("addClass, removeClass, hasClass", function() {

View File

@ -62,7 +62,7 @@ test("jQuery()", function() {
equals( jQuery([1,2,3]).get(1), 2, "Test passing an array to the factory" );
equals( jQuery(document.body).get(0), jQuery('body').get(0), "Test passing an html node to the factory" );
equals( jQuery(document.body).get(0), jQuery("body").get(0), "Test passing an html node to the factory" );
var exec = false;
@ -75,13 +75,13 @@ test("jQuery()", function() {
id: "test3"
});
equals( elem[0].style.width, '10px', 'jQuery() quick setter width');
equals( elem[0].style.paddingLeft, '1px', 'jQuery quick setter css');
equals( elem[0].style.paddingRight, '1px', 'jQuery quick setter css');
equals( elem[0].childNodes.length, 1, 'jQuery quick setter text');
equals( elem[0].firstChild.nodeValue, "test", 'jQuery quick setter text');
equals( elem[0].className, "test2", 'jQuery() quick setter class');
equals( elem[0].id, "test3", 'jQuery() quick setter id');
equals( elem[0].style.width, "10px", "jQuery() quick setter width");
equals( elem[0].style.paddingLeft, "1px", "jQuery quick setter css");
equals( elem[0].style.paddingRight, "1px", "jQuery quick setter css");
equals( elem[0].childNodes.length, 1, "jQuery quick setter text");
equals( elem[0].firstChild.nodeValue, "test", "jQuery quick setter text");
equals( elem[0].className, "test2", "jQuery() quick setter class");
equals( elem[0].id, "test3", "jQuery() quick setter id");
exec = true;
elem.click();
@ -460,7 +460,7 @@ if ( !isLocal ) {
test("isXMLDoc - XML", function() {
expect(3);
stop();
jQuery.get('data/dashboard.xml', function(xml) {
jQuery.get("data/dashboard.xml", function(xml) {
ok( jQuery.isXMLDoc( xml ), "XML document" );
ok( jQuery.isXMLDoc( xml.documentElement ), "XML documentElement" );
ok( jQuery.isXMLDoc( jQuery("tab", xml)[0] ), "XML Tab Element" );
@ -524,15 +524,15 @@ test("jQuery('html')", function() {
// Test very large html string #7990
var i;
var li = '<li>very large html string</li>';
var html = ['<ul>'];
var li = "<li>very large html string</li>";
var html = ["<ul>"];
for ( i = 0; i < 50000; i += 1 ) {
html.push(li);
}
html.push('</ul>');
html = jQuery(html.join(''))[0];
equals( html.nodeName.toUpperCase(), 'UL');
equals( html.firstChild.nodeName.toUpperCase(), 'LI');
html.push("</ul>");
html = jQuery(html.join(""))[0];
equals( html.nodeName.toUpperCase(), "UL");
equals( html.firstChild.nodeName.toUpperCase(), "LI");
equals( html.childNodes.length, 50000 );
});
@ -548,7 +548,7 @@ if ( !isLocal ) {
test("jQuery(selector, xml).text(str) - Loaded via XML document", function() {
expect(2);
stop();
jQuery.get('data/dashboard.xml', function(xml) {
jQuery.get("data/dashboard.xml", function(xml) {
// tests for #1419 where IE was a problem
var tab = jQuery("tab", xml).eq(0);
equals( tab.text(), "blabla", "Verify initial text correct" );
@ -561,12 +561,12 @@ test("jQuery(selector, xml).text(str) - Loaded via XML document", function() {
test("end()", function() {
expect(3);
equals( 'Yahoo', jQuery('#yahoo').parent().end().text(), 'Check for end' );
ok( jQuery('#yahoo').end(), 'Check for end with nothing to end' );
equals( "Yahoo", jQuery("#yahoo").parent().end().text(), "Check for end" );
ok( jQuery("#yahoo").end(), "Check for end with nothing to end" );
var x = jQuery('#yahoo');
var x = jQuery("#yahoo");
x.parent();
equals( 'Yahoo', jQuery('#yahoo').text(), 'Check for non-destructive behaviour' );
equals( "Yahoo", jQuery("#yahoo").text(), "Check for non-destructive behaviour" );
});
test("length", function() {
@ -606,7 +606,7 @@ test("get(-Number)",function() {
test("each(Function)", function() {
expect(1);
var div = jQuery("div");
div.each(function(){this.foo = 'zoo';});
div.each(function(){this.foo = "zoo";});
var pass = true;
for ( var i = 0; i < div.size(); i++ ) {
if ( div.get(i).foo != "zoo" ) pass = false;
@ -625,7 +625,7 @@ test("slice()", function() {
same( $links.slice(-1).get(), q("mark"), "slice(-1)" );
same( $links.eq(1).get(), q("groups"), "eq(1)" );
same( $links.eq('2').get(), q("anchor1"), "eq('2')" );
same( $links.eq("2").get(), q("anchor1"), "eq('2')" );
same( $links.eq(-1).get(), q("mark"), "eq(-1)" );
});
@ -792,7 +792,7 @@ test("jQuery.extend(Object, Object)", function() {
ok( typeof ret.foo != "string", "Check to make sure values equal with coersion (but not actually equal) overwrite correctly" );
var ret = jQuery.extend(true, { foo:"bar" }, { foo:null } );
ok( typeof ret.foo !== 'undefined', "Make sure a null value doesn't crash with deep extend, for #1908" );
ok( typeof ret.foo !== "undefined", "Make sure a null value doesn't crash with deep extend, for #1908" );
var obj = { foo:null };
jQuery.extend(true, obj, { foo:"notnull" } );
@ -845,9 +845,9 @@ test("jQuery.each(Object,Function)", function() {
equals( total, 3, "Looping over an object, with break" );
var f = function(){};
f.foo = 'bar';
f.foo = "bar";
jQuery.each(f, function(i){
f[i] = 'baz';
f[i] = "baz";
});
equals( "baz", f.foo, "Loop over a function" );
});
@ -855,7 +855,7 @@ test("jQuery.each(Object,Function)", function() {
test("jQuery.makeArray", function(){
expect(17);
equals( jQuery.makeArray(jQuery('html>*'))[0].nodeName.toUpperCase(), "HEAD", "Pass makeArray a jQuery object" );
equals( jQuery.makeArray(jQuery("html>*"))[0].nodeName.toUpperCase(), "HEAD", "Pass makeArray a jQuery object" );
equals( jQuery.makeArray(document.getElementsByName("PWD")).slice(0,1)[0].name, "PWD", "Pass makeArray a nodelist" );
@ -885,11 +885,11 @@ test("jQuery.makeArray", function(){
equals( jQuery.makeArray(/a/)[0].constructor, RegExp, "Pass makeArray a regex" );
ok( jQuery.makeArray(document.getElementById('form')).length >= 13, "Pass makeArray a form (treat as elements)" );
ok( jQuery.makeArray(document.getElementById("form")).length >= 13, "Pass makeArray a form (treat as elements)" );
// For #5610
same( jQuery.makeArray({'length': '0'}), [], "Make sure object is coerced properly.");
same( jQuery.makeArray({'length': '5'}), [], "Make sure object is coerced properly.");
same( jQuery.makeArray({length: "0"}), [], "Make sure object is coerced properly.");
same( jQuery.makeArray({length: "5"}), [], "Make sure object is coerced properly.");
});
test("jQuery.isEmptyObject", function(){
@ -938,9 +938,9 @@ test("jQuery.parseJSON", function(){
equals( jQuery.parseJSON( "" ), null, "Nothing in, null out." );
same( jQuery.parseJSON("{}"), {}, "Plain object parsing." );
same( jQuery.parseJSON('{"test":1}'), {"test":1}, "Plain object parsing." );
same( jQuery.parseJSON("{\"test\":1}"), {"test":1}, "Plain object parsing." );
same( jQuery.parseJSON('\n{"test":1}'), {"test":1}, "Make sure leading whitespaces are handled." );
same( jQuery.parseJSON("\n{\"test\":1}"), {"test":1}, "Make sure leading whitespaces are handled." );
try {
jQuery.parseJSON("{a:1}");
@ -964,7 +964,7 @@ test("jQuery.sub() - Static Methods", function(){
topLevelMethod: function() {return this.debug;},
debug: false,
config: {
locale: 'en_US'
locale: "en_US"
},
setup: function(config) {
this.extend(true, this.config, config);
@ -973,37 +973,37 @@ test("jQuery.sub() - Static Methods", function(){
Subclass.fn.extend({subClassMethod: function() { return this;}});
//Test Simple Subclass
ok(Subclass.topLevelMethod() === false, 'Subclass.topLevelMethod thought debug was true');
ok(Subclass.config.locale == 'en_US', Subclass.config.locale + ' is wrong!');
same(Subclass.config.test, undefined, 'Subclass.config.test is set incorrectly');
equal(jQuery.ajax, Subclass.ajax, 'The subclass failed to get all top level methods');
ok(Subclass.topLevelMethod() === false, "Subclass.topLevelMethod thought debug was true");
ok(Subclass.config.locale == "en_US", Subclass.config.locale + " is wrong!");
same(Subclass.config.test, undefined, "Subclass.config.test is set incorrectly");
equal(jQuery.ajax, Subclass.ajax, "The subclass failed to get all top level methods");
//Create a SubSubclass
var SubSubclass = Subclass.sub();
//Make Sure the SubSubclass inherited properly
ok(SubSubclass.topLevelMethod() === false, 'SubSubclass.topLevelMethod thought debug was true');
ok(SubSubclass.config.locale == 'en_US', SubSubclass.config.locale + ' is wrong!');
same(SubSubclass.config.test, undefined, 'SubSubclass.config.test is set incorrectly');
equal(jQuery.ajax, SubSubclass.ajax, 'The subsubclass failed to get all top level methods');
ok(SubSubclass.topLevelMethod() === false, "SubSubclass.topLevelMethod thought debug was true");
ok(SubSubclass.config.locale == "en_US", SubSubclass.config.locale + " is wrong!");
same(SubSubclass.config.test, undefined, "SubSubclass.config.test is set incorrectly");
equal(jQuery.ajax, SubSubclass.ajax, "The subsubclass failed to get all top level methods");
//Modify The Subclass and test the Modifications
SubSubclass.fn.extend({subSubClassMethod: function() { return this;}});
SubSubclass.setup({locale: 'es_MX', test: 'worked'});
SubSubclass.setup({locale: "es_MX", test: "worked"});
SubSubclass.debug = true;
SubSubclass.ajax = function() {return false;};
ok(SubSubclass.topLevelMethod(), 'SubSubclass.topLevelMethod thought debug was false');
same(SubSubclass(document).subClassMethod, Subclass.fn.subClassMethod, 'Methods Differ!');
ok(SubSubclass.config.locale == 'es_MX', SubSubclass.config.locale + ' is wrong!');
ok(SubSubclass.config.test == 'worked', 'SubSubclass.config.test is set incorrectly');
notEqual(jQuery.ajax, SubSubclass.ajax, 'The subsubclass failed to get all top level methods');
ok(SubSubclass.topLevelMethod(), "SubSubclass.topLevelMethod thought debug was false");
same(SubSubclass(document).subClassMethod, Subclass.fn.subClassMethod, "Methods Differ!");
ok(SubSubclass.config.locale == "es_MX", SubSubclass.config.locale + " is wrong!");
ok(SubSubclass.config.test == "worked", "SubSubclass.config.test is set incorrectly");
notEqual(jQuery.ajax, SubSubclass.ajax, "The subsubclass failed to get all top level methods");
//This shows that the modifications to the SubSubClass did not bubble back up to it's superclass
ok(Subclass.topLevelMethod() === false, 'Subclass.topLevelMethod thought debug was true');
ok(Subclass.config.locale == 'en_US', Subclass.config.locale + ' is wrong!');
same(Subclass.config.test, undefined, 'Subclass.config.test is set incorrectly');
same(Subclass(document).subSubClassMethod, undefined, 'subSubClassMethod set incorrectly');
equal(jQuery.ajax, Subclass.ajax, 'The subclass failed to get all top level methods');
ok(Subclass.topLevelMethod() === false, "Subclass.topLevelMethod thought debug was true");
ok(Subclass.config.locale == "en_US", Subclass.config.locale + " is wrong!");
same(Subclass.config.test, undefined, "Subclass.config.test is set incorrectly");
same(Subclass(document).subSubClassMethod, undefined, "subSubClassMethod set incorrectly");
equal(jQuery.ajax, Subclass.ajax, "The subclass failed to get all top level methods");
});
test("jQuery.sub() - .fn Methods", function(){
@ -1014,25 +1014,25 @@ test("jQuery.sub() - .fn Methods", function(){
jQueryDocument = jQuery(document),
selectors, contexts, methods, method, arg, description;
jQueryDocument.toString = function(){ return 'jQueryDocument'; };
jQueryDocument.toString = function(){ return "jQueryDocument"; };
Subclass.fn.subclassMethod = function(){};
SubclassSubclass.fn.subclassSubclassMethod = function(){};
selectors = [
'body',
'html, body',
'<div></div>'
"body",
"html, body",
"<div></div>"
];
methods = [ // all methods that return a new jQuery instance
['eq', 1],
['add', document],
['end'],
['has'],
['closest', 'div'],
['filter', document],
['find', 'div']
["eq", 1],
["add", document],
["end"],
["has"],
["closest", "div"],
["filter", document],
["find", "div"]
];
contexts = [undefined, document, jQueryDocument];
@ -1045,31 +1045,31 @@ test("jQuery.sub() - .fn Methods", function(){
jQuery.each(contexts, function(i, context){
description = '("'+selector+'", '+context+').'+method+'('+(arg||'')+')';
description = "(\""+selector+"\", "+context+")."+method+"("+(arg||"")+")";
same(
jQuery(selector, context)[method](arg).subclassMethod, undefined,
'jQuery'+description+' doesnt have Subclass methods'
"jQuery"+description+" doesn't have Subclass methods"
);
same(
jQuery(selector, context)[method](arg).subclassSubclassMethod, undefined,
'jQuery'+description+' doesnt have SubclassSubclass methods'
"jQuery"+description+" doesn't have SubclassSubclass methods"
);
same(
Subclass(selector, context)[method](arg).subclassMethod, Subclass.fn.subclassMethod,
'Subclass'+description+' has Subclass methods'
"Subclass"+description+" has Subclass methods"
);
same(
Subclass(selector, context)[method](arg).subclassSubclassMethod, undefined,
'Subclass'+description+' doesnt have SubclassSubclass methods'
"Subclass"+description+" doesn't have SubclassSubclass methods"
);
same(
SubclassSubclass(selector, context)[method](arg).subclassMethod, Subclass.fn.subclassMethod,
'SubclassSubclass'+description+' has Subclass methods'
"SubclassSubclass"+description+" has Subclass methods"
);
same(
SubclassSubclass(selector, context)[method](arg).subclassSubclassMethod, SubclassSubclass.fn.subclassSubclassMethod,
'SubclassSubclass'+description+' has SubclassSubclass methods'
"SubclassSubclass"+description+" has SubclassSubclass methods"
);
});

View File

@ -3,13 +3,13 @@ module("css", { teardown: moduleTeardown });
test("css(String|Hash)", function() {
expect(41);
equals( jQuery('#main').css("display"), 'block', 'Check for css property "display"');
equals( jQuery("#main").css("display"), "block", "Check for css property \"display\"");
ok( jQuery('#nothiddendiv').is(':visible'), 'Modifying CSS display: Assert element is visible');
jQuery('#nothiddendiv').css({display: 'none'});
ok( !jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is hidden');
jQuery('#nothiddendiv').css({display: 'block'});
ok( jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is visible');
ok( jQuery("#nothiddendiv").is(":visible"), "Modifying CSS display: Assert element is visible");
jQuery("#nothiddendiv").css({display: "none"});
ok( !jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is hidden");
jQuery("#nothiddendiv").css({display: "block"});
ok( jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is visible");
var div = jQuery( "<div>" );
@ -32,34 +32,34 @@ test("css(String|Hash)", function() {
div2.remove();
// handle negative numbers by ignoring #1599, #4216
jQuery('#nothiddendiv').css({ 'width': 1, 'height': 1 });
jQuery("#nothiddendiv").css( {width: 1, height: 1} );
var width = parseFloat(jQuery('#nothiddendiv').css('width')), height = parseFloat(jQuery('#nothiddendiv').css('height'));
jQuery('#nothiddendiv').css({ width: -1, height: -1 });
equals( parseFloat(jQuery('#nothiddendiv').css('width')), width, 'Test negative width ignored')
equals( parseFloat(jQuery('#nothiddendiv').css('height')), height, 'Test negative height ignored')
var width = parseFloat(jQuery("#nothiddendiv").css("width")), height = parseFloat(jQuery("#nothiddendiv").css("height"));
jQuery("#nothiddendiv").css({ width: -1, height: -1 });
equals( parseFloat(jQuery("#nothiddendiv").css("width")), width, "Test negative width ignored")
equals( parseFloat(jQuery("#nothiddendiv").css("height")), height, "Test negative height ignored")
equals( jQuery('<div style="display: none;">').css('display'), 'none', 'Styles on disconnected nodes');
equals( jQuery("<div style='display: none;'>").css("display"), "none", "Styles on disconnected nodes");
jQuery('#floatTest').css({'float': 'right'});
equals( jQuery('#floatTest').css('float'), 'right', 'Modified CSS float using "float": Assert float is right');
jQuery('#floatTest').css({'font-size': '30px'});
equals( jQuery('#floatTest').css('font-size'), '30px', 'Modified CSS font-size: Assert font-size is 30px');
jQuery("#floatTest").css({"float": "right"});
equals( jQuery("#floatTest").css("float"), "right", "Modified CSS float using \"float\": Assert float is right");
jQuery("#floatTest").css({"font-size": "30px"});
equals( jQuery("#floatTest").css("font-size"), "30px", "Modified CSS font-size: Assert font-size is 30px");
jQuery.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {
jQuery('#foo').css({opacity: n});
equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
jQuery('#foo').css({opacity: parseFloat(n)});
equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
jQuery.each("0,0.25,0.5,0.75,1".split(","), function(i, n) {
jQuery("#foo").css({opacity: n});
equals( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
jQuery("#foo").css({opacity: parseFloat(n)});
equals( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
});
jQuery('#foo').css({opacity: ''});
equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when set to an empty String" );
jQuery("#foo").css({opacity: ""});
equals( jQuery("#foo").css("opacity"), "1", "Assert opacity is 1 when set to an empty String" );
equals( jQuery('#empty').css('opacity'), '0', "Assert opacity is accessible via filter property set in stylesheet in IE" );
jQuery('#empty').css({ opacity: '1' });
equals( jQuery('#empty').css('opacity'), '1', "Assert opacity is taken from style attribute when set vs stylesheet in IE with filters" );
equals( jQuery("#empty").css("opacity"), "0", "Assert opacity is accessible via filter property set in stylesheet in IE" );
jQuery("#empty").css({ opacity: "1" });
equals( jQuery("#empty").css("opacity"), "1", "Assert opacity is taken from style attribute when set vs stylesheet in IE with filters" );
var div = jQuery('#nothiddendiv'), child = jQuery('#nothiddendivchild');
var div = jQuery("#nothiddendiv"), child = jQuery("#nothiddendivchild");
equals( parseInt(div.css("fontSize")), 16, "Verify fontSize px set." );
equals( parseInt(div.css("font-size")), 16, "Verify fontSize px set." );
@ -107,7 +107,7 @@ test("css(String|Hash)", function() {
test("css() explicit and relative values", function() {
expect(9);
var $elem = jQuery('#nothiddendiv');
var $elem = jQuery("#nothiddendiv");
$elem.css({ width: 1, height: 1 });
equals( $elem.width(), 1, "Initial css set or width/height works (hash)" );
@ -140,28 +140,28 @@ test("css() explicit and relative values", function() {
test("css(String, Object)", function() {
expect(22);
ok( jQuery('#nothiddendiv').is(':visible'), 'Modifying CSS display: Assert element is visible');
jQuery('#nothiddendiv').css("display", 'none');
ok( !jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is hidden');
jQuery('#nothiddendiv').css("display", 'block');
ok( jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is visible');
ok( jQuery("#nothiddendiv").is(":visible"), "Modifying CSS display: Assert element is visible");
jQuery("#nothiddendiv").css("display", "none");
ok( !jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is hidden");
jQuery("#nothiddendiv").css("display", "block");
ok( jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is visible");
jQuery("#nothiddendiv").css("top", "-1em");
ok( jQuery("#nothiddendiv").css("top"), -16, "Check negative number in EMs." );
jQuery('#floatTest').css('float', 'left');
equals( jQuery('#floatTest').css('float'), 'left', 'Modified CSS float using "float": Assert float is left');
jQuery('#floatTest').css('font-size', '20px');
equals( jQuery('#floatTest').css('font-size'), '20px', 'Modified CSS font-size: Assert font-size is 20px');
jQuery("#floatTest").css("float", "left");
equals( jQuery("#floatTest").css("float"), "left", "Modified CSS float using \"float\": Assert float is left");
jQuery("#floatTest").css("font-size", "20px");
equals( jQuery("#floatTest").css("font-size"), "20px", "Modified CSS font-size: Assert font-size is 20px");
jQuery.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {
jQuery('#foo').css('opacity', n);
equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
jQuery('#foo').css('opacity', parseFloat(n));
equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
jQuery.each("0,0.25,0.5,0.75,1".split(","), function(i, n) {
jQuery("#foo").css("opacity", n);
equals( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
jQuery("#foo").css("opacity", parseFloat(n));
equals( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
});
jQuery('#foo').css('opacity', '');
equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when set to an empty String" );
jQuery("#foo").css("opacity", "");
equals( jQuery("#foo").css("opacity"), "1", "Assert opacity is 1 when set to an empty String" );
// using contents will get comments regular, text, and comment nodes
var j = jQuery("#nonnodes").contents();
@ -181,7 +181,7 @@ test("css(String, Object)", function() {
// Test for Bug #5509
var success = true;
try {
jQuery('#foo').css("backgroundColor", "rgba(0, 0, 0, 0.1)");
jQuery("#foo").css("backgroundColor", "rgba(0, 0, 0, 0.1)");
}
catch (e) {
success = false;
@ -192,19 +192,19 @@ test("css(String, Object)", function() {
if ( !jQuery.support.opacity ) {
test("css(String, Object) for MSIE", function() {
// for #1438, IE throws JS error when filter exists but doesn't have opacity in it
jQuery('#foo').css("filter", "progid:DXImageTransform.Microsoft.Chroma(color='red');");
equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when a different filter is set in IE, #1438" );
jQuery("#foo").css("filter", "progid:DXImageTransform.Microsoft.Chroma(color='red');");
equals( jQuery("#foo").css("opacity"), "1", "Assert opacity is 1 when a different filter is set in IE, #1438" );
var filterVal = "progid:DXImageTransform.Microsoft.Alpha(opacity=30) progid:DXImageTransform.Microsoft.Blur(pixelradius=5)";
var filterVal2 = "progid:DXImageTransform.Microsoft.alpha(opacity=100) progid:DXImageTransform.Microsoft.Blur(pixelradius=5)";
var filterVal3 = "progid:DXImageTransform.Microsoft.Blur(pixelradius=5)";
jQuery('#foo').css("filter", filterVal);
equals( jQuery('#foo').css("filter"), filterVal, "css('filter', val) works" );
jQuery('#foo').css("opacity", 1);
equals( jQuery('#foo').css("filter"), filterVal2, "Setting opacity in IE doesn't duplicate opacity filter" );
equals( jQuery('#foo').css("opacity"), 1, "Setting opacity in IE with other filters works" );
jQuery('#foo').css("filter", filterVal3).css("opacity", 1);
ok( jQuery('#foo').css("filter").indexOf(filterVal3) !== -1, "Setting opacity in IE doesn't clobber other filters" );
jQuery("#foo").css("filter", filterVal);
equals( jQuery("#foo").css("filter"), filterVal, "css('filter', val) works" );
jQuery("#foo").css("opacity", 1);
equals( jQuery("#foo").css("filter"), filterVal2, "Setting opacity in IE doesn't duplicate opacity filter" );
equals( jQuery("#foo").css("opacity"), 1, "Setting opacity in IE with other filters works" );
jQuery("#foo").css("filter", filterVal3).css("opacity", 1);
ok( jQuery("#foo").css("filter").indexOf(filterVal3) !== -1, "Setting opacity in IE doesn't clobber other filters" );
});
}
@ -343,14 +343,14 @@ test("jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", funct
test(":visible selector works properly on table elements (bug #4512)", function () {
expect(1);
jQuery('#table').html('<tr><td style="display:none">cell</td><td>cell</td></tr>');
equals(jQuery('#table td:visible').length, 1, "hidden cell is not perceived as visible");
jQuery("#table").html("<tr><td style='display:none'>cell</td><td>cell</td></tr>");
equals(jQuery("#table td:visible").length, 1, "hidden cell is not perceived as visible");
});
test(":visible selector works properly on children with a hidden parent (bug #4512)", function () {
expect(1);
jQuery('#table').css('display', 'none').html('<tr><td>cell</td><td>cell</td></tr>');
equals(jQuery('#table td:visible').length, 0, "hidden cell children not perceived as visible");
jQuery("#table").css("display", "none").html("<tr><td>cell</td><td>cell</td></tr>");
equals(jQuery("#table td:visible").length, 0, "hidden cell children not perceived as visible");
});
test("internal ref to elem.runtimeStyle (bug #7608)", function () {

View File

@ -283,11 +283,11 @@ test(".data(String) and .data(String, Object)", function() {
// #3748
var $elem = jQuery({exists:true});
equals( $elem.data('nothing'), undefined, "Non-existent data returns undefined");
equals( $elem.data('null',null).data('null'), null, "null's are preserved");
equals( $elem.data('emptyString','').data('emptyString'), '', "Empty strings are preserved");
equals( $elem.data('false',false).data('false'), false, "false's are preserved");
equals( $elem.data('exists'), undefined, "Existing data is not returned" );
equals( $elem.data("nothing"), undefined, "Non-existent data returns undefined");
equals( $elem.data("null", null).data("null"), null, "null's are preserved");
equals( $elem.data("emptyString", "").data("emptyString"), "", "Empty strings are preserved");
equals( $elem.data("false", false).data("false"), false, "false's are preserved");
equals( $elem.data("exists"), undefined, "Existing data is not returned" );
// Clean up
$elem.removeData();
@ -316,7 +316,7 @@ test("data-* attributes", function() {
div.remove();
child.appendTo('#main');
child.appendTo("#main");
equals( child.data("myobj"), "old data", "Value accessed from data-* attribute");
child.data("myobj", "replaced");
@ -365,19 +365,19 @@ test("data-* attributes", function() {
.attr("data-null", "null")
.attr("data-string", "test");
strictEqual( child.data('true'), true, "Primitive true read from attribute");
strictEqual( child.data('false'), false, "Primitive false read from attribute");
strictEqual( child.data('five'), 5, "Primitive number read from attribute");
strictEqual( child.data('point'), 5.5, "Primitive number read from attribute");
strictEqual( child.data('pointe'), 5500, "Primitive number read from attribute");
strictEqual( child.data('pointbad'), "5..5", "Bad number read from attribute");
strictEqual( child.data('pointbad2'), "-.", "Bad number read from attribute");
strictEqual( child.data('badjson'), "{123}", "Bad number read from attribute");
strictEqual( child.data('badjson2'), "[abc]", "Bad number read from attribute");
strictEqual( child.data('empty'), "", "Empty string read from attribute");
strictEqual( child.data('space'), " ", "Empty string read from attribute");
strictEqual( child.data('null'), null, "Primitive null read from attribute");
strictEqual( child.data('string'), "test", "Typical string read from attribute");
strictEqual( child.data("true"), true, "Primitive true read from attribute");
strictEqual( child.data("false"), false, "Primitive false read from attribute");
strictEqual( child.data("five"), 5, "Primitive number read from attribute");
strictEqual( child.data("point"), 5.5, "Primitive number read from attribute");
strictEqual( child.data("pointe"), 5500, "Primitive number read from attribute");
strictEqual( child.data("pointbad"), "5..5", "Bad number read from attribute");
strictEqual( child.data("pointbad2"), "-.", "Bad number read from attribute");
strictEqual( child.data("badjson"), "{123}", "Bad number read from attribute");
strictEqual( child.data("badjson2"), "[abc]", "Bad number read from attribute");
strictEqual( child.data("empty"), "", "Empty string read from attribute");
strictEqual( child.data("space"), " ", "Empty string read from attribute");
strictEqual( child.data("null"), null, "Primitive null read from attribute");
strictEqual( child.data("string"), "test", "Typical string read from attribute");
child.remove();
@ -401,12 +401,12 @@ test("data-* attributes", function() {
same(jQuery(elem).data("stuff"), [2,8], "Check stuff property");
break;
default:
ok(false, ["Assertion failed on index ", index, ", with data ", data].join(''));
ok(false, ["Assertion failed on index ", index, ", with data ", data].join(""));
}
}
var metadata = '<ol><li class="test test2" data-foo="bar" data-bar="baz" data-arr="[1,2]">Some stuff</li><li class="test test2" data-test="bar" data-bar="baz">Some stuff</li><li class="test test2" data-zoooo="bar" data-bar=\'{"test":"baz"}\'>Some stuff</li><li class="test test2" data-number=true data-stuff="[2,8]">Some stuff</li></ol>',
elem = jQuery(metadata).appendTo('#main');
var metadata = "<ol><li class='test test2' data-foo='bar' data-bar='baz' data-arr='[1,2]'>Some stuff</li><li class='test test2' data-test='bar' data-bar='baz'>Some stuff</li><li class='test test2' data-zoooo='bar' data-bar='{\"test\":\"baz\"}'>Some stuff</li><li class='test test2' data-number=true data-stuff='[2,8]'>Some stuff</li></ol>",
elem = jQuery(metadata).appendTo("#main");
elem.find("li").each(testData);
elem.remove();
@ -483,7 +483,7 @@ if (window.JSON && window.JSON.stringify) {
var obj = { foo: "bar" };
jQuery.data(obj, "hidden", true);
equals( JSON.stringify(obj), '{"foo":"bar"}', "Expando is hidden from JSON.stringify" );
equals( JSON.stringify(obj), "{\"foo\":\"bar\"}", "Expando is hidden from JSON.stringify" );
});
}