Test Paragraph.
Test Paragraph.
* @resultTest Paragraph.
* - * @test ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible'); - * $('#foo').css({display: 'none'}); - * ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden'); - * $('#foo').css({display: 'block'}); - * ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible'); - * $('#floatTest').css({styleFloat: 'right'}); - * ok( $('#floatTest').css('styleFloat') == 'right', 'Modified CSS float using "styleFloat": Assert float is right'); - * $('#floatTest').css({cssFloat: 'left'}); - * ok( $('#floatTest').css('cssFloat') == 'left', 'Modified CSS float using "cssFloat": Assert float is left'); - * $('#floatTest').css({'float': 'right'}); - * ok( $('#floatTest').css('float') == 'right', 'Modified CSS float using "float": Assert float is right'); - * $('#floatTest').css({'font-size': '30px'}); - * ok( $('#floatTest').css('font-size') == '30px', 'Modified CSS font-size: Assert font-size is 30px'); - * * @name css * @type jQuery * @param Hash prop A set of key/value pairs to set as style properties. @@ -561,21 +462,6 @@ jQuery.fn = jQuery.prototype = { * @resultTest Paragraph.
* @desc Changes the color of all paragraphs to red * - * - * @test ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible'); - * $('#foo').css('display', 'none'); - * ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden'); - * $('#foo').css('display', 'block'); - * ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible'); - * $('#floatTest').css('styleFloat', 'left'); - * ok( $('#floatTest').css('styleFloat') == 'left', 'Modified CSS float using "styleFloat": Assert float is left'); - * $('#floatTest').css('cssFloat', 'right'); - * ok( $('#floatTest').css('cssFloat') == 'right', 'Modified CSS float using "cssFloat": Assert float is right'); - * $('#floatTest').css('float', 'left'); - * ok( $('#floatTest').css('float') == 'left', 'Modified CSS float using "float": Assert float is left'); - * $('#floatTest').css('font-size', '20px'); - * ok( $('#floatTest').css('font-size') == '20px', 'Modified CSS font-size: Assert font-size is 20px'); - * * @name css * @type jQuery * @param String key The name of the property to set. @@ -595,9 +481,6 @@ jQuery.fn = jQuery.prototype = { * @beforeTest Paragraph.
* @result Test Paragraph. * - * @test var expected = "This link has class=\"blog\": Simon Willison's Weblog"; - * ok( $('#sap').text() == expected, 'Check for merged text of more then one element.' ); - * * @name text * @type String * @cat DOM @@ -633,11 +516,6 @@ jQuery.fn = jQuery.prototype = { * @beforeTest Paragraph.
* @resultTest Paragraph.
Test Paragraph.
* @resultTest Paragraph.
I would like to say:
* @resultI would like to say: Hello
* - * @test var defaultText = 'Try them out:' - * var result = $('#first').append('buga'); - * ok( result.text() == defaultText + 'buga', 'Check if text appending works' ); - * ok( $('#select3').append('').find('option:last-child').attr('value') == 'appendTest', 'Appending html options to select element'); - * * @name append * @type jQuery * @param String html A string of HTML, that will be created on the fly and appended to the target. @@ -722,10 +590,6 @@ jQuery.fn = jQuery.prototype = { * @beforeI would like to say:
Hello * @resultI would like to say: Hello
* - * @test var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:"; - * $('#sap').append(document.getElementById('first')); - * ok( expected == $('#sap').text(), "Check for appending of element" ); - * * @name append * @type jQuery * @param Element elem A DOM element that will be appended. @@ -741,10 +605,6 @@ jQuery.fn = jQuery.prototype = { * @beforeI would like to say:
Hello * @resultI would like to say: Hello
* - * @test var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo"; - * $('#sap').append([document.getElementById('first'), document.getElementById('yahoo')]); - * ok( expected == $('#sap').text(), "Check for appending of array of elements" ); - * * @name append * @type jQuery * @param ArrayI would like to say:
* @resultHelloI would like to say:
* - * @test var defaultText = 'Try them out:' - * var result = $('#first').prepend('buga'); - * ok( result.text() == 'buga' + defaultText, 'Check if text prepending works' ); - * ok( $('#select3').prepend('').find('option:first-child').attr('value') == 'prependTest', 'Prepending html options to select element'); - * * @name prepend * @type jQuery * @param String html A string of HTML, that will be created on the fly and appended to the target. @@ -786,10 +641,6 @@ jQuery.fn = jQuery.prototype = { * @beforeI would like to say:
Hello * @resultHelloI would like to say:
* - * @test var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog"; - * $('#sap').prepend(document.getElementById('first')); - * ok( expected == $('#sap').text(), "Check for prepending of element" ); - * * @name prepend * @type jQuery * @param Element elem A DOM element that will be appended. @@ -805,10 +656,6 @@ jQuery.fn = jQuery.prototype = { * @beforeI would like to say:
Hello * @resultHelloI would like to say:
* - * @test var expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog"; - * $('#sap').prepend([document.getElementById('first'), document.getElementById('yahoo')]); - * ok( expected == $('#sap').text(), "Check for prepending of array of elements" ); - * * @name prepend * @type jQuery * @param ArrayI would like to say:
* @result HelloI would like to say:
* - * @test var expected = 'This is a normal link: bugaYahoo'; - * $('#yahoo').before('buga'); - * ok( expected == $('#en').text(), 'Insert String before' ); - * * @name before * @type jQuery * @param String html A string of HTML, that will be created on the fly and appended to the target. @@ -845,10 +688,6 @@ jQuery.fn = jQuery.prototype = { * @beforeI would like to say:
Hello * @result HelloI would like to say:
* - * @test var expected = "This is a normal link: Try them out:Yahoo"; - * $('#yahoo').before(document.getElementById('first')); - * ok( expected == $('#en').text(), "Insert element before" ); - * * @name before * @type jQuery * @param Element elem A DOM element that will be appended. @@ -862,10 +701,6 @@ jQuery.fn = jQuery.prototype = { * @beforeI would like to say:
Hello * @result HelloI would like to say:
* - * @test var expected = "This is a normal link: Try them out:diveintomarkYahoo"; - * $('#yahoo').before([document.getElementById('first'), document.getElementById('mark')]); - * ok( expected == $('#en').text(), "Insert array of elements before" ); - * * @name before * @type jQuery * @param ArrayI would like to say:
* @resultI would like to say:
Hello * - * @test var expected = 'This is a normal link: Yahoobuga'; - * $('#yahoo').after('buga'); - * ok( expected == $('#en').text(), 'Insert String after' ); - * * @name after * @type jQuery * @param String html A string of HTML, that will be created on the fly and appended to the target. @@ -902,10 +733,6 @@ jQuery.fn = jQuery.prototype = { * @before HelloI would like to say:
* @resultI would like to say:
Hello * - * @test var expected = "This is a normal link: YahooTry them out:"; - * $('#yahoo').after(document.getElementById('first')); - * ok( expected == $('#en').text(), "Insert element after" ); - * * @name after * @type jQuery * @param Element elem A DOM element that will be appended. @@ -919,10 +746,6 @@ jQuery.fn = jQuery.prototype = { * @before HelloI would like to say:
* @resultI would like to say:
Hello * - * @test var expected = "This is a normal link: YahooTry them out:diveintomark"; - * $('#yahoo').after([document.getElementById('first'), document.getElementById('mark')]); - * ok( expected == $('#en').text(), "Insert array of elements after" ); - * * @name after * @type jQuery * @param ArrayHello, how are you?
* @result $("p").find("span").end() == [...
] * - * @test ok( 'Yahoo' == $('#yahoo').parent().end().text(), 'Check for end' ); - * ok( $('#yahoo').end(), 'Check for end with nothing to end' ); - * * @name end * @type jQuery * @cat DOM/Traversing @@ -968,8 +788,6 @@ jQuery.fn = jQuery.prototype = { * @beforeHello, how are you?
* @result $("p").find("span") == [ Hello ] * - * @test ok( 'Yahoo' == $('#foo').find('.blogTest').text(), 'Check for find' ); - * * @name find * @type jQuery * @param String expr An expression to search with. @@ -992,11 +810,6 @@ jQuery.fn = jQuery.prototype = { * @before Hello, how are you?
* @result HelloHello, how are you?
* - * @test ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Assert text for #en' ); - * var clone = $('#yahoo').clone(); - * ok( 'Try them out:Yahoo' == $('#first').append(clone).text(), 'Check for clone' ); - * ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Reassert text for #en' ); - * * @name clone * @type jQuery * @cat DOM/Manipulation @@ -1019,14 +832,6 @@ jQuery.fn = jQuery.prototype = { * @beforeHello
How are you?
* @result $("p").filter(".selected") == [Hello
] * - * @test isSet( $("input").filter(":checked").get(), q("radio2", "check1"), "Filter elements" ); - * @test $("input").filter(":checked",function(i){ - * ok( this == q("radio2", "check1")[i], "Filter elements, context" ); - * }); - * @test $("#main > p#ap > a").filter("#foobar",function(){},function(i){ - * ok( this == q("google","groups", "mark")[i], "Filter elements, else context" ); - * }); - * * @name filter * @type jQuery * @param String expr An expression to search with. @@ -1058,7 +863,7 @@ jQuery.fn = jQuery.prototype = { for ( var i = 0; i < t.length; i++ ) if ( jQuery.filter(t[i],[a]).r.length ) return a; - return false; + return null; }) || t.constructor == Boolean && @@ -1093,15 +898,13 @@ jQuery.fn = jQuery.prototype = { * @beforeHello
Hello Again
* @result [Hello
] * - * @test ok($("#main > p#ap > a").not("#google").length == 2, ".not") - * * @name not * @type jQuery * @param String expr An expression with which to remove matching elements * @cat DOM/Traversing */ not: function(t) { - return this.pushStack( t.constructor == String ? + return this.pushStack( typeof t == "string" ? jQuery.filter(t,this,false).r : jQuery.grep(this,function(a){ return a != t; }), arguments ); }, @@ -1148,7 +951,7 @@ jQuery.fn = jQuery.prototype = { * @cat DOM/Traversing */ add: function(t) { - return this.pushStack( jQuery.merge( this, t.constructor == String ? + return this.pushStack( jQuery.merge( this, typeof t == "string" ? jQuery.find(t) : t.constructor == Array ? t : [t] ), arguments ); }, @@ -1172,29 +975,6 @@ jQuery.fn = jQuery.prototype = { * @result false * @desc An invalid expression always returns false. * - * @test ok( $('#form').is('form'), 'Check for element: A form must be a form' ); - * ok( !$('#form').is('div'), 'Check for element: A form is not a div' ); - * ok( $('#mark').is('.blog'), 'Check for class: Expected class "blog"' ); - * ok( !$('#mark').is('.link'), 'Check for class: Did not expect class "link"' ); - * ok( $('#simon').is('.blog.link'), 'Check for multiple classes: Expected classes "blog" and "link"' ); - * ok( !$('#simon').is('.blogTest'), 'Check for multiple classes: Expected classes "blog" and "link", but not "blogTest"' ); - * ok( $('#en').is('[@lang="en"]'), 'Check for attribute: Expected attribute lang to be "en"' ); - * ok( !$('#en').is('[@lang="de"]'), 'Check for attribute: Expected attribute lang to be "en", not "de"' ); - * ok( $('#text1').is('[@type="text"]'), 'Check for attribute: Expected attribute type to be "text"' ); - * ok( !$('#text1').is('[@type="radio"]'), 'Check for attribute: Expected attribute type to be "text", not "radio"' ); - * ok( $('#text2').is(':disabled'), 'Check for pseudoclass: Expected to be disabled' ); - * ok( !$('#text1').is(':disabled'), 'Check for pseudoclass: Expected not disabled' ); - * ok( $('#radio2').is(':checked'), 'Check for pseudoclass: Expected to be checked' ); - * ok( !$('#radio1').is(':checked'), 'Check for pseudoclass: Expected not checked' ); - * ok( $('#foo').is('[p]'), 'Check for child: Expected a child "p" element' ); - * ok( !$('#foo').is('[ul]'), 'Check for child: Did not expect "ul" element' ); - * ok( $('#foo').is('[p][a][code]'), 'Check for childs: Expected "p", "a" and "code" child elements' ); - * ok( !$('#foo').is('[p][a][code][ol]'), 'Check for childs: Expected "p", "a" and "code" child elements, but no "ol"' ); - * ok( !$('#foo').is(0), 'Expected false for an invalid expression - 0' ); - * ok( !$('#foo').is(null), 'Expected false for an invalid expression - null' ); - * ok( !$('#foo').is(''), 'Expected false for an invalid expression - ""' ); - * ok( !$('#foo').is(undefined), 'Expected false for an invalid expression - undefined' ); - * * @name is * @type Boolean * @param String expr The expression with which to filter @@ -1307,14 +1087,6 @@ jQuery.fn = jQuery.prototype = { * jQuery.extend(settings, options); * @result settings == { validate: true, limit: 5, name: "bar" } * - * @test var settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" }; - * var options = { xnumber2: 1, xstring2: "x", xxx: "newstring" }; - * var optionsCopy = { xnumber2: 1, xstring2: "x", xxx: "newstring" }; - * var merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" }; - * jQuery.extend(settings, options); - * isSet( settings, merged, "Check if extended: settings must be extended" ); - * isSet ( options, optionsCopy, "Check if not modified: options must not be modified" ); - * * @name $.extend * @param Object obj The object to extend * @param Object prop The object that will be merged into the first. @@ -1349,7 +1121,7 @@ jQuery.extend({ jQuery.each( jQuery.macros.axis, function(i,n){ jQuery.fn[ i ] = function(a) { var ret = jQuery.map(this,n); - if ( a && a.constructor == String ) + if ( a && typeof a == "string" ) ret = jQuery.filter(a,ret).r; return this.pushStack( ret, arguments ); }; @@ -1472,7 +1244,7 @@ jQuery.extend({ if ( p == "height" || p == "width" ) { var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"]; - for ( var i in d ) { + for ( var i=0; iHello
And Again
* @result [Hello
,And Again
] * - * @test isSet( $("#en").siblings().get(), q("sndp", "sap"), "Check for siblings" ); - * * @name siblings * @type jQuery * @cat DOM/Traversing @@ -3133,9 +2773,6 @@ jQuery.macros = { * @beforeHello Again
And Again
* @result [Hello Again
] * - * @test isSet( $("#sndp").siblings("[code]").get(), q("sap"), "Check for filtered siblings (has code child element)" ); - * isSet( $("#sndp").siblings("[a]").get(), q("en", "sap"), "Check for filtered siblings (has anchor child element)" ); - * * @name siblings * @type jQuery * @param String expr An expression to filter the sibling Elements with @@ -3152,8 +2789,6 @@ jQuery.macros = { * @beforeHello
And Again
* @result [ Hello Again ] * - * @test isSet( $("#foo").children().get(), q("sndp", "en", "sap"), "Check for children" ); - * * @name children * @type jQuery * @cat DOM/Traversing @@ -3167,8 +2802,6 @@ jQuery.macros = { * @beforeHello Again
And Again
Hello Again
] * - * @test isSet( $("#foo").children("[code]").get(), q("sndp", "sap"), "Check for filtered children" ); - * * @name children * @type jQuery * @param String expr An expression to filter the child Elements with @@ -3202,12 +2835,6 @@ jQuery.macros = { * @before * @result [Hello
] * - * @test var pass = true, div = $("div"); - * div.show().each(function(){ - * if ( this.style.display == "none" ) pass = false; - * }); - * ok( pass, "Show" ); - * * @name show * @type jQuery * @cat Effects @@ -3266,14 +2893,6 @@ jQuery.macros = { * @beforeHello
* @result [Hello
] * - * @test var div = $("div"); - * div.addClass("test"); - * var pass = true; - * for ( var i = 0; i < div.size(); i++ ) { - * if ( div.get(i).className.indexOf("test") == -1 ) pass = false; - * } - * ok( pass, "Add Class" ); - * * @name addClass * @type jQuery * @param String class A CSS class to add to the elements @@ -3290,24 +2909,6 @@ jQuery.macros = { * @beforeHello
* @result [Hello
] * - * @test var div = $("div").addClass("test"); - * div.removeClass("test"); - * var pass = true; - * for ( var i = 0; i < div.size(); i++ ) { - * if ( div.get(i).className.indexOf("test") != -1 ) pass = false; - * } - * ok( pass, "Remove Class" ); - * - * reset(); - * - * var div = $("div").addClass("test").addClass("foo").addClass("bar"); - * div.removeClass("test").removeClass("bar").removeClass("foo"); - * var pass = true; - * for ( var i = 0; i < div.size(); i++ ) { - * if ( div.get(i).className.match(/test|bar|foo/) ) pass = false; - * } - * ok( pass, "Remove multiple classes" ); - * * @name removeClass * @type jQuery * @param String class A CSS class to remove from the elements @@ -3318,8 +2919,8 @@ jQuery.macros = { }, /** - * Adds the specified class if it is present, removes it if it is - * not present. + * Adds the specified class if it is not present, removes it if it is + * present. * * @example $("p").toggleClass("selected") * @beforeHello
Hello Again
@@ -3416,8 +3017,6 @@ jQuery.macros = { * @cat Events */ bind: function( type, fn ) { - if ( fn.constructor == String ) - fn = new Function("e", ( !fn.indexOf(".") ? "jQuery(this)" : "return " ) + fn); jQuery.event.add( this, type, fn ); },