" );
+ td = table.find( "td" ).eq( 0 );
td.attr( "rowspan", "2" );
- assert.equal( td[ 0 ]["rowSpan"], 2, "Check rowspan is correctly set" );
+ assert.equal( td[ 0 ][ "rowSpan" ], 2, "Check rowspan is correctly set" );
td.attr( "colspan", "2" );
- assert.equal( td[ 0 ]["colSpan"], 2, "Check colspan is correctly set" );
- table.attr("cellspacing", "2");
- assert.equal( table[ 0 ]["cellSpacing"], "2", "Check cellspacing is correctly set" );
+ assert.equal( td[ 0 ][ "colSpan" ], 2, "Check colspan is correctly set" );
+ table.attr( "cellspacing", "2" );
+ assert.equal( table[ 0 ][ "cellSpacing" ], "2", "Check cellspacing is correctly set" );
- assert.equal( jQuery("#area1").attr("value"), undefined, "Value attribute is distinct from value property." );
+ assert.equal( jQuery( "#area1" ).attr( "value" ), undefined, "Value attribute is distinct from value property." );
// for #1070
- jQuery("#name").attr( "someAttr", "0" );
- assert.equal( jQuery("#name").attr("someAttr"), "0", "Set attribute to a string of '0'" );
- jQuery("#name").attr( "someAttr", 0 );
- assert.equal( jQuery("#name").attr("someAttr"), "0", "Set attribute to the number 0" );
- jQuery("#name").attr( "someAttr", 1 );
- assert.equal( jQuery("#name").attr("someAttr"), "1", "Set attribute to the number 1" );
+ jQuery( "#name" ).attr( "someAttr", "0" );
+ assert.equal( jQuery( "#name" ).attr( "someAttr" ), "0", "Set attribute to a string of '0'" );
+ jQuery( "#name" ).attr( "someAttr", 0 );
+ assert.equal( jQuery( "#name" ).attr( "someAttr" ), "0", "Set attribute to the number 0" );
+ jQuery( "#name" ).attr( "someAttr", 1 );
+ assert.equal( jQuery( "#name" ).attr( "someAttr" ), "1", "Set attribute to the number 1" );
// using contents will get comments regular, text, and comment nodes
- j = jQuery("#nonnodes").contents();
+ j = jQuery( "#nonnodes" ).contents();
j.attr( "name", "attrvalue" );
- assert.equal( j.attr("name"), "attrvalue", "Check node,textnode,comment for attr" );
- j.removeAttr("name");
+ assert.equal( j.attr( "name" ), "attrvalue", "Check node,textnode,comment for attr" );
+ j.removeAttr( "name" );
// Type
- type = jQuery("#check2").attr("type");
+ type = jQuery( "#check2" ).attr( "type" );
try {
- jQuery("#check2").attr( "type", "hidden" );
+ jQuery( "#check2" ).attr( "type", "hidden" );
assert.ok( true, "No exception thrown on input type change" );
- } catch( e ) {
+ } catch ( e ) {
assert.ok( true, "Exception thrown on input type change: " + e );
}
- check = document.createElement("input");
+ check = document.createElement( "input" );
thrown = true;
try {
jQuery( check ).attr( "type", "checkbox" );
- } catch( e ) {
+ } catch ( e ) {
thrown = false;
}
assert.ok( thrown, "Exception thrown when trying to change type property" );
- assert.equal( "checkbox", jQuery( check ).attr("type"), "Verify that you can change the type of an input element that isn't in the DOM" );
+ assert.equal( "checkbox", jQuery( check ).attr( "type" ), "Verify that you can change the type of an input element that isn't in the DOM" );
- check = jQuery("");
+ check = jQuery( "" );
thrown = true;
try {
check.attr( "type", "checkbox" );
- } catch( e ) {
+ } catch ( e ) {
thrown = false;
}
assert.ok( thrown, "Exception thrown when trying to change type property" );
- assert.equal( "checkbox", check.attr("type"), "Verify that you can change the type of an input element that isn't in the DOM" );
+ assert.equal( "checkbox", check.attr( "type" ), "Verify that you can change the type of an input element that isn't in the DOM" );
- button = jQuery("#button");
+ button = jQuery( "#button" );
try {
button.attr( "type", "submit" );
assert.ok( true, "No exception thrown on button type change" );
- } catch( e ) {
+ } catch ( e ) {
assert.ok( true, "Exception thrown on button type change: " + e );
}
$radio = jQuery( "", {
"value": "sup",
"type": "radio"
- }).appendTo("#testForm");
+ } ).appendTo( "#testForm" );
assert.equal( $radio.val(), "sup", "Value is not reset when type is set after value on a radio" );
// Setting attributes on svg elements (bug #3116)
@@ -460,16 +461,16 @@ QUnit.test( "attr(String, Object)", function( assert ) {
"" +
""
- ).appendTo("body");
- assert.equal( $svg.attr( "cx", 100 ).attr("cx"), "100", "Set attribute on svg element" );
+ ).appendTo( "body" );
+ assert.equal( $svg.attr( "cx", 100 ).attr( "cx" ), "100", "Set attribute on svg element" );
$svg.remove();
// undefined values are chainable
- jQuery("#name").attr( "maxlength", "5" ).removeAttr("nonexisting");
- assert.equal( typeof jQuery("#name").attr( "maxlength", undefined ), "object", ".attr('attribute', undefined) is chainable (#5571)" );
- assert.equal( jQuery("#name").attr( "maxlength", undefined ).attr("maxlength"), "5", ".attr('attribute', undefined) does not change value (#5571)" );
- assert.equal( jQuery("#name").attr( "nonexisting", undefined ).attr("nonexisting"), undefined, ".attr('attribute', undefined) does not create attribute (#5571)" );
-});
+ jQuery( "#name" ).attr( "maxlength", "5" ).removeAttr( "nonexisting" );
+ assert.equal( typeof jQuery( "#name" ).attr( "maxlength", undefined ), "object", ".attr('attribute', undefined) is chainable (#5571)" );
+ assert.equal( jQuery( "#name" ).attr( "maxlength", undefined ).attr( "maxlength" ), "5", ".attr('attribute', undefined) does not change value (#5571)" );
+ assert.equal( jQuery( "#name" ).attr( "nonexisting", undefined ).attr( "nonexisting" ), undefined, ".attr('attribute', undefined) does not create attribute (#5571)" );
+} );
QUnit.test( "attr - extending the boolean attrHandle", function( assert ) {
assert.expect( 1 );
@@ -483,18 +484,18 @@ QUnit.test( "attr - extending the boolean attrHandle", function( assert ) {
called = false;
jQuery( "input" ).attr( "checked" );
assert.ok( called, "The boolean attrHandle does not drop custom attrHandles" );
-});
+} );
QUnit.test( "attr(String, Object) - Loaded via XML document", function( assert ) {
assert.expect( 2 );
var xml = createDashboardXML(),
titles = [];
- jQuery( "tab", xml ).each(function() {
- titles.push( jQuery( this ).attr("title") );
- });
+ jQuery( "tab", xml ).each( function() {
+ titles.push( jQuery( this ).attr( "title" ) );
+ } );
assert.equal( titles[ 0 ], "Location", "attr() in XML context: Check first title" );
assert.equal( titles[ 1 ], "Users", "attr() in XML context: Check second title" );
-});
+} );
QUnit.test( "attr(String, Object) - Loaded via XML fragment", function( assert ) {
assert.expect( 2 );
@@ -502,121 +503,121 @@ QUnit.test( "attr(String, Object) - Loaded via XML fragment", function( assert )
$frag = jQuery( frag );
$frag.attr( "test", "some value" );
- assert.equal( $frag.attr("test"), "some value", "set attribute" );
+ assert.equal( $frag.attr( "test" ), "some value", "set attribute" );
$frag.attr( "test", null );
- assert.equal( $frag.attr("test"), undefined, "remove attribute" );
-});
+ assert.equal( $frag.attr( "test" ), undefined, "remove attribute" );
+} );
QUnit.test( "attr('tabindex')", function( assert ) {
assert.expect( 8 );
// elements not natively tabbable
- assert.equal( jQuery("#listWithTabIndex").attr("tabindex"), "5", "not natively tabbable, with tabindex set to 0" );
- assert.equal( jQuery("#divWithNoTabIndex").attr("tabindex"), undefined, "not natively tabbable, no tabindex set" );
+ assert.equal( jQuery( "#listWithTabIndex" ).attr( "tabindex" ), "5", "not natively tabbable, with tabindex set to 0" );
+ assert.equal( jQuery( "#divWithNoTabIndex" ).attr( "tabindex" ), undefined, "not natively tabbable, no tabindex set" );
// anchor with href
- assert.equal( jQuery("#linkWithNoTabIndex").attr("tabindex"), undefined, "anchor with href, no tabindex set" );
- assert.equal( jQuery("#linkWithTabIndex").attr("tabindex"), "2", "anchor with href, tabindex set to 2" );
- assert.equal( jQuery("#linkWithNegativeTabIndex").attr("tabindex"), "-1", "anchor with href, tabindex set to -1" );
+ assert.equal( jQuery( "#linkWithNoTabIndex" ).attr( "tabindex" ), undefined, "anchor with href, no tabindex set" );
+ assert.equal( jQuery( "#linkWithTabIndex" ).attr( "tabindex" ), "2", "anchor with href, tabindex set to 2" );
+ assert.equal( jQuery( "#linkWithNegativeTabIndex" ).attr( "tabindex" ), "-1", "anchor with href, tabindex set to -1" );
// anchor without href
- assert.equal( jQuery("#linkWithNoHrefWithNoTabIndex").attr("tabindex"), undefined, "anchor without href, no tabindex set" );
- assert.equal( jQuery("#linkWithNoHrefWithTabIndex").attr("tabindex"), "1", "anchor without href, tabindex set to 2" );
- assert.equal( jQuery("#linkWithNoHrefWithNegativeTabIndex").attr("tabindex"), "-1", "anchor without href, no tabindex set" );
-});
+ assert.equal( jQuery( "#linkWithNoHrefWithNoTabIndex" ).attr( "tabindex" ), undefined, "anchor without href, no tabindex set" );
+ assert.equal( jQuery( "#linkWithNoHrefWithTabIndex" ).attr( "tabindex" ), "1", "anchor without href, tabindex set to 2" );
+ assert.equal( jQuery( "#linkWithNoHrefWithNegativeTabIndex" ).attr( "tabindex" ), "-1", "anchor without href, no tabindex set" );
+} );
QUnit.test( "attr('tabindex', value)", function( assert ) {
assert.expect( 9 );
- var element = jQuery("#divWithNoTabIndex");
- assert.equal( element.attr("tabindex"), undefined, "start with no tabindex" );
+ var element = jQuery( "#divWithNoTabIndex" );
+ assert.equal( element.attr( "tabindex" ), undefined, "start with no tabindex" );
// set a positive string
element.attr( "tabindex", "1" );
- assert.equal( element.attr("tabindex"), "1", "set tabindex to 1 (string)" );
+ assert.equal( element.attr( "tabindex" ), "1", "set tabindex to 1 (string)" );
// set a zero string
element.attr( "tabindex", "0" );
- assert.equal( element.attr("tabindex"), "0", "set tabindex to 0 (string)" );
+ assert.equal( element.attr( "tabindex" ), "0", "set tabindex to 0 (string)" );
// set a negative string
element.attr( "tabindex", "-1" );
- assert.equal( element.attr("tabindex"), "-1", "set tabindex to -1 (string)" );
+ assert.equal( element.attr( "tabindex" ), "-1", "set tabindex to -1 (string)" );
// set a positive number
element.attr( "tabindex", 1 );
- assert.equal( element.attr("tabindex"), "1", "set tabindex to 1 (number)" );
+ assert.equal( element.attr( "tabindex" ), "1", "set tabindex to 1 (number)" );
// set a zero number
element.attr( "tabindex", 0 );
- assert.equal(element.attr("tabindex"), "0", "set tabindex to 0 (number)");
+ assert.equal( element.attr( "tabindex" ), "0", "set tabindex to 0 (number)" );
// set a negative number
element.attr( "tabindex", -1 );
- assert.equal( element.attr("tabindex"), "-1", "set tabindex to -1 (number)" );
+ assert.equal( element.attr( "tabindex" ), "-1", "set tabindex to -1 (number)" );
- element = jQuery("#linkWithTabIndex");
- assert.equal( element.attr("tabindex"), "2", "start with tabindex 2" );
+ element = jQuery( "#linkWithTabIndex" );
+ assert.equal( element.attr( "tabindex" ), "2", "start with tabindex 2" );
element.attr( "tabindex", -1 );
- assert.equal( element.attr("tabindex"), "-1", "set negative tabindex" );
-});
+ assert.equal( element.attr( "tabindex" ), "-1", "set negative tabindex" );
+} );
QUnit.test( "removeAttr(String)", function( assert ) {
assert.expect( 12 );
var $first;
- assert.equal( jQuery("#mark").removeAttr("class").attr("class"), undefined, "remove class" );
- assert.equal( jQuery("#form").removeAttr("id").attr("id"), undefined, "Remove id" );
- assert.equal( jQuery("#foo").attr( "style", "position:absolute;" ).removeAttr("style").attr("style"), undefined, "Check removing style attribute" );
- assert.equal( jQuery("#form").attr( "style", "position:absolute;" ).removeAttr("style").attr("style"), undefined, "Check removing style attribute on a form" );
- assert.equal( jQuery("").appendTo("#foo").removeAttr("style").prop("style").cssText, "", "Check removing style attribute (#9699 Webkit)" );
- assert.equal( jQuery("#fx-test-group").attr( "height", "3px" ).removeAttr("height").get( 0 ).style.height, "1px", "Removing height attribute has no effect on height set with style attribute" );
+ assert.equal( jQuery( "#mark" ).removeAttr( "class" ).attr( "class" ), undefined, "remove class" );
+ assert.equal( jQuery( "#form" ).removeAttr( "id" ).attr( "id" ), undefined, "Remove id" );
+ assert.equal( jQuery( "#foo" ).attr( "style", "position:absolute;" ).removeAttr( "style" ).attr( "style" ), undefined, "Check removing style attribute" );
+ assert.equal( jQuery( "#form" ).attr( "style", "position:absolute;" ).removeAttr( "style" ).attr( "style" ), undefined, "Check removing style attribute on a form" );
+ assert.equal( jQuery( "" ).appendTo( "#foo" ).removeAttr( "style" ).prop( "style" ).cssText, "", "Check removing style attribute (#9699 Webkit)" );
+ assert.equal( jQuery( "#fx-test-group" ).attr( "height", "3px" ).removeAttr( "height" ).get( 0 ).style.height, "1px", "Removing height attribute has no effect on height set with style attribute" );
- jQuery("#check1").removeAttr("checked").prop( "checked", true ).removeAttr("checked");
- assert.equal( document.getElementById("check1").checked, false, "removeAttr sets boolean properties to false" );
- jQuery("#text1").prop( "readOnly", true ).removeAttr("readonly");
- assert.equal( document.getElementById("text1").readOnly, false, "removeAttr sets boolean properties to false" );
+ jQuery( "#check1" ).removeAttr( "checked" ).prop( "checked", true ).removeAttr( "checked" );
+ assert.equal( document.getElementById( "check1" ).checked, false, "removeAttr sets boolean properties to false" );
+ jQuery( "#text1" ).prop( "readOnly", true ).removeAttr( "readonly" );
+ assert.equal( document.getElementById( "text1" ).readOnly, false, "removeAttr sets boolean properties to false" );
- jQuery("#option2c").removeAttr("selected");
- assert.equal( jQuery("#option2d").attr("selected"), "selected", "Removing `selected` from an option that is not selected does not remove selected from the currently selected option (#10870)" );
+ jQuery( "#option2c" ).removeAttr( "selected" );
+ assert.equal( jQuery( "#option2d" ).attr( "selected" ), "selected", "Removing `selected` from an option that is not selected does not remove selected from the currently selected option (#10870)" );
try {
- $first = jQuery("#first").attr( "contenteditable", "true" ).removeAttr("contenteditable");
- assert.equal( $first.attr("contenteditable"), undefined, "Remove the contenteditable attribute" );
- } catch( e ) {
+ $first = jQuery( "#first" ).attr( "contenteditable", "true" ).removeAttr( "contenteditable" );
+ assert.equal( $first.attr( "contenteditable" ), undefined, "Remove the contenteditable attribute" );
+ } catch ( e ) {
assert.ok( false, "Removing contenteditable threw an error (#10429)" );
}
- $first = jQuery("");
- assert.equal( $first.attr("Case"), "mixed", "case of attribute doesn't matter" );
- $first.removeAttr("Case");
+ $first = jQuery( "" );
+ assert.equal( $first.attr( "Case" ), "mixed", "case of attribute doesn't matter" );
+ $first.removeAttr( "Case" );
assert.equal( $first.attr( "Case" ), undefined, "mixed-case attribute was removed" );
-});
+} );
QUnit.test( "removeAttr(String) in XML", function( assert ) {
assert.expect( 7 );
var xml = createDashboardXML(),
iwt = jQuery( "infowindowtab", xml );
- assert.equal( iwt.attr("normal"), "ab", "Check initial value" );
- iwt.removeAttr("Normal");
- assert.equal( iwt.attr("normal"), "ab", "Should still be there" );
- iwt.removeAttr("normal");
- assert.equal( iwt.attr("normal"), undefined, "Removed" );
+ assert.equal( iwt.attr( "normal" ), "ab", "Check initial value" );
+ iwt.removeAttr( "Normal" );
+ assert.equal( iwt.attr( "normal" ), "ab", "Should still be there" );
+ iwt.removeAttr( "normal" );
+ assert.equal( iwt.attr( "normal" ), undefined, "Removed" );
- assert.equal( iwt.attr("mixedCase"), "yes", "Check initial value" );
- assert.equal( iwt.attr("mixedcase"), undefined, "toLowerCase not work good" );
- iwt.removeAttr("mixedcase");
- assert.equal( iwt.attr("mixedCase"), "yes", "Should still be there" );
- iwt.removeAttr("mixedCase");
- assert.equal( iwt.attr("mixedCase"), undefined, "Removed" );
-});
+ assert.equal( iwt.attr( "mixedCase" ), "yes", "Check initial value" );
+ assert.equal( iwt.attr( "mixedcase" ), undefined, "toLowerCase not work good" );
+ iwt.removeAttr( "mixedcase" );
+ assert.equal( iwt.attr( "mixedCase" ), "yes", "Should still be there" );
+ iwt.removeAttr( "mixedCase" );
+ assert.equal( iwt.attr( "mixedCase" ), undefined, "Removed" );
+} );
QUnit.test( "removeAttr(Multi String, variable space width)", function( assert ) {
assert.expect( 8 );
- var div = jQuery(""),
+ var div = jQuery( "" ),
tests = {
id: "a",
alt: "b",
@@ -626,46 +627,46 @@ QUnit.test( "removeAttr(Multi String, variable space width)", function( assert )
jQuery.each( tests, function( key, val ) {
assert.equal( div.attr( key ), val, "Attribute `" + key + "` exists, and has a value of `" + val + "`" );
- });
+ } );
div.removeAttr( "id alt title rel " );
jQuery.each( tests, function( key ) {
assert.equal( div.attr( key ), undefined, "Attribute `" + key + "` was removed" );
- });
-});
+ } );
+} );
QUnit.test( "prop(String, Object)", function( assert ) {
assert.expect( 17 );
- assert.equal( jQuery("#text1").prop("value"), "Test", "Check for value attribute" );
- assert.equal( jQuery("#text1").prop( "value", "Test2" ).prop("defaultValue"), "Test", "Check for defaultValue attribute" );
- assert.equal( jQuery("#select2").prop("selectedIndex"), 3, "Check for selectedIndex attribute" );
- assert.equal( jQuery("#foo").prop("nodeName").toUpperCase(), "DIV", "Check for nodeName attribute" );
- assert.equal( jQuery("#foo").prop("tagName").toUpperCase(), "DIV", "Check for tagName attribute" );
- assert.equal( jQuery("").prop("selected"), false, "Check selected attribute on disconnected element." );
+ assert.equal( jQuery( "#text1" ).prop( "value" ), "Test", "Check for value attribute" );
+ assert.equal( jQuery( "#text1" ).prop( "value", "Test2" ).prop( "defaultValue" ), "Test", "Check for defaultValue attribute" );
+ assert.equal( jQuery( "#select2" ).prop( "selectedIndex" ), 3, "Check for selectedIndex attribute" );
+ assert.equal( jQuery( "#foo" ).prop( "nodeName" ).toUpperCase(), "DIV", "Check for nodeName attribute" );
+ assert.equal( jQuery( "#foo" ).prop( "tagName" ).toUpperCase(), "DIV", "Check for tagName attribute" );
+ assert.equal( jQuery( "" ).prop( "selected" ), false, "Check selected attribute on disconnected element." );
- assert.equal( jQuery("#listWithTabIndex").prop("tabindex"), 5, "Check retrieving tabindex" );
- jQuery("#text1").prop( "readonly", true );
- assert.equal( document.getElementById("text1").readOnly, true, "Check setting readOnly property with 'readonly'" );
- assert.equal( jQuery("#label-for").prop("for"), "action", "Check retrieving htmlFor" );
- jQuery("#text1").prop("class", "test");
- assert.equal( document.getElementById("text1").className, "test", "Check setting className with 'class'" );
- assert.equal( jQuery("#text1").prop("maxlength"), 30, "Check retrieving maxLength" );
- jQuery("#table").prop( "cellspacing", 1 );
- assert.equal( jQuery("#table").prop("cellSpacing"), "1", "Check setting and retrieving cellSpacing" );
- jQuery("#table").prop( "cellpadding", 1 );
- assert.equal( jQuery("#table").prop("cellPadding"), "1", "Check setting and retrieving cellPadding" );
- jQuery("#table").prop( "rowspan", 1 );
- assert.equal( jQuery("#table").prop("rowSpan"), 1, "Check setting and retrieving rowSpan" );
- jQuery("#table").prop( "colspan", 1 );
- assert.equal( jQuery("#table").prop("colSpan"), 1, "Check setting and retrieving colSpan" );
- jQuery("#table").prop( "usemap", 1 );
- assert.equal( jQuery("#table").prop("useMap"), 1, "Check setting and retrieving useMap" );
- jQuery("#table").prop( "frameborder", 1 );
- assert.equal( jQuery("#table").prop("frameBorder"), 1, "Check setting and retrieving frameBorder" );
-});
+ assert.equal( jQuery( "#listWithTabIndex" ).prop( "tabindex" ), 5, "Check retrieving tabindex" );
+ jQuery( "#text1" ).prop( "readonly", true );
+ assert.equal( document.getElementById( "text1" ).readOnly, true, "Check setting readOnly property with 'readonly'" );
+ assert.equal( jQuery( "#label-for" ).prop( "for" ), "action", "Check retrieving htmlFor" );
+ jQuery( "#text1" ).prop( "class", "test" );
+ assert.equal( document.getElementById( "text1" ).className, "test", "Check setting className with 'class'" );
+ assert.equal( jQuery( "#text1" ).prop( "maxlength" ), 30, "Check retrieving maxLength" );
+ jQuery( "#table" ).prop( "cellspacing", 1 );
+ assert.equal( jQuery( "#table" ).prop( "cellSpacing" ), "1", "Check setting and retrieving cellSpacing" );
+ jQuery( "#table" ).prop( "cellpadding", 1 );
+ assert.equal( jQuery( "#table" ).prop( "cellPadding" ), "1", "Check setting and retrieving cellPadding" );
+ jQuery( "#table" ).prop( "rowspan", 1 );
+ assert.equal( jQuery( "#table" ).prop( "rowSpan" ), 1, "Check setting and retrieving rowSpan" );
+ jQuery( "#table" ).prop( "colspan", 1 );
+ assert.equal( jQuery( "#table" ).prop( "colSpan" ), 1, "Check setting and retrieving colSpan" );
+ jQuery( "#table" ).prop( "usemap", 1 );
+ assert.equal( jQuery( "#table" ).prop( "useMap" ), 1, "Check setting and retrieving useMap" );
+ jQuery( "#table" ).prop( "frameborder", 1 );
+ assert.equal( jQuery( "#table" ).prop( "frameBorder" ), 1, "Check setting and retrieving frameBorder" );
+} );
QUnit.test( "prop(String, Object) on null/undefined", function( assert ) {
@@ -675,243 +676,243 @@ QUnit.test( "prop(String, Object) on null/undefined", function( assert ) {
body = document.body,
$body = jQuery( body );
- assert.ok( $body.prop("nextSibling") === null, "Make sure a null expando returns null" );
- body["foo"] = "bar";
- assert.equal( $body.prop("foo"), "bar", "Make sure the expando is preferred over the dom attribute" );
- body["foo"] = undefined;
- assert.ok( $body.prop("foo") === undefined, "Make sure the expando is preferred over the dom attribute, even if undefined" );
+ assert.ok( $body.prop( "nextSibling" ) === null, "Make sure a null expando returns null" );
+ body[ "foo" ] = "bar";
+ assert.equal( $body.prop( "foo" ), "bar", "Make sure the expando is preferred over the dom attribute" );
+ body[ "foo" ] = undefined;
+ assert.ok( $body.prop( "foo" ) === undefined, "Make sure the expando is preferred over the dom attribute, even if undefined" );
- select = document.createElement("select");
- optgroup = document.createElement("optgroup");
- option = document.createElement("option");
+ select = document.createElement( "select" );
+ optgroup = document.createElement( "optgroup" );
+ option = document.createElement( "option" );
optgroup.appendChild( option );
select.appendChild( optgroup );
- assert.equal( jQuery( option ).prop("selected"), true, "Make sure that a single option is selected, even when in an optgroup." );
- assert.equal( jQuery( document ).prop("nodeName"), "#document", "prop works correctly on document nodes (bug #7451)." );
+ assert.equal( jQuery( option ).prop( "selected" ), true, "Make sure that a single option is selected, even when in an optgroup." );
+ assert.equal( jQuery( document ).prop( "nodeName" ), "#document", "prop works correctly on document nodes (bug #7451)." );
- attributeNode = document.createAttribute("irrelevant");
- commentNode = document.createComment("some comment");
- textNode = document.createTextNode("some text");
+ attributeNode = document.createAttribute( "irrelevant" );
+ commentNode = document.createComment( "some comment" );
+ textNode = document.createTextNode( "some text" );
obj = {};
jQuery.each( [ document, attributeNode, commentNode, textNode, obj, "#firstp" ], function( i, ele ) {
- assert.strictEqual( jQuery( ele ).prop("nonexisting"), undefined, "prop works correctly for non existing attributes (bug #7500)." );
- });
+ assert.strictEqual( jQuery( ele ).prop( "nonexisting" ), undefined, "prop works correctly for non existing attributes (bug #7500)." );
+ } );
obj = {};
jQuery.each( [ document, obj ], function( i, ele ) {
var $ele = jQuery( ele );
$ele.prop( "nonexisting", "foo" );
- assert.equal( $ele.prop("nonexisting"), "foo", "prop(name, value) works correctly for non existing attributes (bug #7500)." );
- });
- jQuery( document ).removeProp("nonexisting");
+ assert.equal( $ele.prop( "nonexisting" ), "foo", "prop(name, value) works correctly for non existing attributes (bug #7500)." );
+ } );
+ jQuery( document ).removeProp( "nonexisting" );
- $form = jQuery("#form").prop( "enctype", "multipart/form-data" );
- assert.equal( $form.prop("enctype"), "multipart/form-data", "Set the enctype of a form (encoding in IE6/7 #6743)" );
-});
+ $form = jQuery( "#form" ).prop( "enctype", "multipart/form-data" );
+ assert.equal( $form.prop( "enctype" ), "multipart/form-data", "Set the enctype of a form (encoding in IE6/7 #6743)" );
+} );
QUnit.test( "prop('tabindex')", function( assert ) {
assert.expect( 11 );
// inputs without tabIndex attribute
- assert.equal( jQuery("#inputWithoutTabIndex").prop("tabindex"), 0, "input without tabindex" );
- assert.equal( jQuery("#buttonWithoutTabIndex").prop("tabindex"), 0, "button without tabindex" );
- assert.equal( jQuery("#textareaWithoutTabIndex").prop("tabindex"), 0, "textarea without tabindex" );
+ assert.equal( jQuery( "#inputWithoutTabIndex" ).prop( "tabindex" ), 0, "input without tabindex" );
+ assert.equal( jQuery( "#buttonWithoutTabIndex" ).prop( "tabindex" ), 0, "button without tabindex" );
+ assert.equal( jQuery( "#textareaWithoutTabIndex" ).prop( "tabindex" ), 0, "textarea without tabindex" );
// elements not natively tabbable
- assert.equal( jQuery("#listWithTabIndex").prop("tabindex"), 5, "not natively tabbable, with tabindex set to 0" );
- assert.equal( jQuery("#divWithNoTabIndex").prop("tabindex"), -1, "not natively tabbable, no tabindex set" );
+ assert.equal( jQuery( "#listWithTabIndex" ).prop( "tabindex" ), 5, "not natively tabbable, with tabindex set to 0" );
+ assert.equal( jQuery( "#divWithNoTabIndex" ).prop( "tabindex" ), -1, "not natively tabbable, no tabindex set" );
// anchor with href
- assert.equal( jQuery("#linkWithNoTabIndex").prop("tabindex"), 0, "anchor with href, no tabindex set" );
- assert.equal( jQuery("#linkWithTabIndex").prop("tabindex"), 2, "anchor with href, tabindex set to 2" );
- assert.equal( jQuery("#linkWithNegativeTabIndex").prop("tabindex"), -1, "anchor with href, tabindex set to -1" );
+ assert.equal( jQuery( "#linkWithNoTabIndex" ).prop( "tabindex" ), 0, "anchor with href, no tabindex set" );
+ assert.equal( jQuery( "#linkWithTabIndex" ).prop( "tabindex" ), 2, "anchor with href, tabindex set to 2" );
+ assert.equal( jQuery( "#linkWithNegativeTabIndex" ).prop( "tabindex" ), -1, "anchor with href, tabindex set to -1" );
// anchor without href
- assert.equal( jQuery("#linkWithNoHrefWithNoTabIndex").prop("tabindex"), -1, "anchor without href, no tabindex set" );
- assert.equal( jQuery("#linkWithNoHrefWithTabIndex").prop("tabindex"), 1, "anchor without href, tabindex set to 2" );
- assert.equal( jQuery("#linkWithNoHrefWithNegativeTabIndex").prop("tabindex"), -1, "anchor without href, no tabindex set" );
-});
+ assert.equal( jQuery( "#linkWithNoHrefWithNoTabIndex" ).prop( "tabindex" ), -1, "anchor without href, no tabindex set" );
+ assert.equal( jQuery( "#linkWithNoHrefWithTabIndex" ).prop( "tabindex" ), 1, "anchor without href, tabindex set to 2" );
+ assert.equal( jQuery( "#linkWithNoHrefWithNegativeTabIndex" ).prop( "tabindex" ), -1, "anchor without href, no tabindex set" );
+} );
QUnit.test( "prop('tabindex', value)", function( assert ) {
assert.expect( 10 );
var clone,
- element = jQuery("#divWithNoTabIndex");
+ element = jQuery( "#divWithNoTabIndex" );
- assert.equal( element.prop("tabindex"), -1, "start with no tabindex" );
+ assert.equal( element.prop( "tabindex" ), -1, "start with no tabindex" );
// set a positive string
element.prop( "tabindex", "1" );
- assert.equal( element.prop("tabindex"), 1, "set tabindex to 1 (string)" );
+ assert.equal( element.prop( "tabindex" ), 1, "set tabindex to 1 (string)" );
// set a zero string
element.prop( "tabindex", "0" );
- assert.equal( element.prop("tabindex"), 0, "set tabindex to 0 (string)" );
+ assert.equal( element.prop( "tabindex" ), 0, "set tabindex to 0 (string)" );
// set a negative string
element.prop( "tabindex", "-1" );
- assert.equal( element.prop("tabindex"), -1, "set tabindex to -1 (string)" );
+ assert.equal( element.prop( "tabindex" ), -1, "set tabindex to -1 (string)" );
// set a positive number
element.prop( "tabindex", 1 );
- assert.equal( element.prop("tabindex"), 1, "set tabindex to 1 (number)" );
+ assert.equal( element.prop( "tabindex" ), 1, "set tabindex to 1 (number)" );
// set a zero number
element.prop( "tabindex", 0 );
- assert.equal( element.prop("tabindex"), 0, "set tabindex to 0 (number)" );
+ assert.equal( element.prop( "tabindex" ), 0, "set tabindex to 0 (number)" );
// set a negative number
element.prop( "tabindex", -1 );
- assert.equal( element.prop("tabindex"), -1, "set tabindex to -1 (number)" );
+ assert.equal( element.prop( "tabindex" ), -1, "set tabindex to -1 (number)" );
- element = jQuery("#linkWithTabIndex");
- assert.equal( element.prop("tabindex"), 2, "start with tabindex 2" );
+ element = jQuery( "#linkWithTabIndex" );
+ assert.equal( element.prop( "tabindex" ), 2, "start with tabindex 2" );
element.prop( "tabindex", -1 );
- assert.equal( element.prop("tabindex"), -1, "set negative tabindex" );
+ assert.equal( element.prop( "tabindex" ), -1, "set negative tabindex" );
clone = element.clone();
clone.prop( "tabindex", 1 );
- assert.equal( clone[ 0 ].getAttribute("tabindex"), "1", "set tabindex on cloned element" );
-});
+ assert.equal( clone[ 0 ].getAttribute( "tabindex" ), "1", "set tabindex on cloned element" );
+} );
QUnit.test( "removeProp(String)", function( assert ) {
assert.expect( 6 );
- var attributeNode = document.createAttribute("irrelevant"),
- commentNode = document.createComment("some comment"),
- textNode = document.createTextNode("some text"),
+ var attributeNode = document.createAttribute( "irrelevant" ),
+ commentNode = document.createComment( "some comment" ),
+ textNode = document.createTextNode( "some text" ),
obj = {};
assert.strictEqual(
- jQuery( "#firstp" ).prop( "nonexisting", "foo" ).removeProp( "nonexisting" )[ 0 ]["nonexisting"],
+ jQuery( "#firstp" ).prop( "nonexisting", "foo" ).removeProp( "nonexisting" )[ 0 ][ "nonexisting" ],
undefined,
"removeprop works correctly on DOM element nodes"
);
jQuery.each( [ document, obj ], function( i, ele ) {
var $ele = jQuery( ele );
- $ele.prop( "nonexisting", "foo" ).removeProp("nonexisting");
- assert.strictEqual( ele["nonexisting"], undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." );
- });
+ $ele.prop( "nonexisting", "foo" ).removeProp( "nonexisting" );
+ assert.strictEqual( ele[ "nonexisting" ], undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." );
+ } );
jQuery.each( [ commentNode, textNode, attributeNode ], function( i, ele ) {
var $ele = jQuery( ele );
- $ele.prop( "nonexisting", "foo" ).removeProp("nonexisting");
- assert.strictEqual( ele["nonexisting"], undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." );
- });
-});
+ $ele.prop( "nonexisting", "foo" ).removeProp( "nonexisting" );
+ assert.strictEqual( ele[ "nonexisting" ], undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." );
+ } );
+} );
QUnit.test( "val() after modification", function( assert ) {
assert.expect( 1 );
- document.getElementById("text1").value = "bla";
- assert.equal( jQuery("#text1").val(), "bla", "Check for modified value of input element" );
-});
-
+ document.getElementById( "text1" ).value = "bla";
+ assert.equal( jQuery( "#text1" ).val(), "bla", "Check for modified value of input element" );
+} );
QUnit.test( "val()", function( assert ) {
assert.expect( 20 + ( jQuery.fn.serialize ? 6 : 0 ) );
var checks, $button;
- assert.equal( jQuery("#text1").val(), "Test", "Check for value of input element" );
+ assert.equal( jQuery( "#text1" ).val(), "Test", "Check for value of input element" );
+
// ticket #1714 this caused a JS error in IE
- assert.equal( jQuery("#first").val(), "", "Check a paragraph element to see if it has a value" );
- assert.ok( jQuery([]).val() === undefined, "Check an empty jQuery object will return undefined from val" );
+ assert.equal( jQuery( "#first" ).val(), "", "Check a paragraph element to see if it has a value" );
+ assert.ok( jQuery( [] ).val() === undefined, "Check an empty jQuery object will return undefined from val" );
- assert.equal( jQuery("#select2").val(), "3", "Call val() on a single='single' select" );
+ assert.equal( jQuery( "#select2" ).val(), "3", "Call val() on a single='single' select" );
- assert.deepEqual( jQuery("#select3").val(), [ "1", "2" ], "Call val() on a multiple='multiple' select" );
+ assert.deepEqual( jQuery( "#select3" ).val(), [ "1", "2" ], "Call val() on a multiple='multiple' select" );
- assert.equal( jQuery("#option3c").val(), "2", "Call val() on a option element with value" );
+ assert.equal( jQuery( "#option3c" ).val(), "2", "Call val() on a option element with value" );
- assert.equal( jQuery("#option3a").val(), "", "Call val() on a option element with empty value" );
+ assert.equal( jQuery( "#option3a" ).val(), "", "Call val() on a option element with empty value" );
- assert.equal( jQuery("#option3e").val(), "no value", "Call val() on a option element with no value attribute" );
+ assert.equal( jQuery( "#option3e" ).val(), "no value", "Call val() on a option element with no value attribute" );
- assert.equal( jQuery("#option3a").val(), "", "Call val() on a option element with no value attribute" );
+ assert.equal( jQuery( "#option3a" ).val(), "", "Call val() on a option element with no value attribute" );
- jQuery("#select3").val("");
- assert.deepEqual( jQuery("#select3").val(), [""], "Call val() on a multiple='multiple' select" );
+ jQuery( "#select3" ).val( "" );
+ assert.deepEqual( jQuery( "#select3" ).val(), [ "" ], "Call val() on a multiple='multiple' select" );
- assert.deepEqual( jQuery("#select4").val(), [], "Call val() on multiple='multiple' select with all disabled options" );
+ assert.deepEqual( jQuery( "#select4" ).val(), [], "Call val() on multiple='multiple' select with all disabled options" );
- jQuery("#select4 optgroup").add("#select4 > [disabled]").attr( "disabled", false );
- assert.deepEqual( jQuery("#select4").val(), [ "2", "3" ], "Call val() on multiple='multiple' select with some disabled options" );
+ jQuery( "#select4 optgroup" ).add( "#select4 > [disabled]" ).attr( "disabled", false );
+ assert.deepEqual( jQuery( "#select4" ).val(), [ "2", "3" ], "Call val() on multiple='multiple' select with some disabled options" );
- jQuery("#select4").attr( "disabled", true );
- assert.deepEqual( jQuery("#select4").val(), [ "2", "3" ], "Call val() on disabled multiple='multiple' select" );
+ jQuery( "#select4" ).attr( "disabled", true );
+ assert.deepEqual( jQuery( "#select4" ).val(), [ "2", "3" ], "Call val() on disabled multiple='multiple' select" );
- assert.equal( jQuery("#select5").val(), "3", "Check value on ambiguous select." );
+ assert.equal( jQuery( "#select5" ).val(), "3", "Check value on ambiguous select." );
- jQuery("#select5").val( 1 );
- assert.equal( jQuery("#select5").val(), "1", "Check value on ambiguous select." );
+ jQuery( "#select5" ).val( 1 );
+ assert.equal( jQuery( "#select5" ).val(), "1", "Check value on ambiguous select." );
- jQuery("#select5").val( 3 );
- assert.equal( jQuery("#select5").val(), "3", "Check value on ambiguous select." );
+ jQuery( "#select5" ).val( 3 );
+ assert.equal( jQuery( "#select5" ).val(), "3", "Check value on ambiguous select." );
assert.strictEqual(
- jQuery("").val(),
+ jQuery( "" ).val(),
null,
"Select-one with only option disabled (#12584)"
);
if ( jQuery.fn.serialize ) {
- checks = jQuery("").appendTo("#form");
+ checks = jQuery( "" ).appendTo( "#form" );
assert.deepEqual( checks.serialize(), "", "Get unchecked values." );
assert.equal( checks.eq( 3 ).val(), "on", "Make sure a value of 'on' is provided if none is specified." );
- checks.val([ "2" ]);
+ checks.val( [ "2" ] );
assert.deepEqual( checks.serialize(), "test=2", "Get a single checked value." );
- checks.val([ "1", "" ]);
+ checks.val( [ "1", "" ] );
assert.deepEqual( checks.serialize(), "test=1&test=", "Get multiple checked values." );
- checks.val([ "", "2" ]);
+ checks.val( [ "", "2" ] );
assert.deepEqual( checks.serialize(), "test=2&test=", "Get multiple checked values." );
- checks.val([ "1", "on" ]);
+ checks.val( [ "1", "on" ] );
assert.deepEqual( checks.serialize(), "test=1&test=on", "Get multiple checked values." );
checks.remove();
}
- $button = jQuery("").insertAfter("#button");
+ $button = jQuery( "" ).insertAfter( "#button" );
assert.equal( $button.val(), "foobar", "Value retrieval on a button does not return innerHTML" );
- assert.equal( $button.val("baz").html(), "text", "Setting the value does not change innerHTML" );
+ assert.equal( $button.val( "baz" ).html(), "text", "Setting the value does not change innerHTML" );
- assert.equal( jQuery("").val("test").attr("value"), "test", "Setting value sets the value attribute" );
-});
+ assert.equal( jQuery( "" ).val( "test" ).attr( "value" ), "test", "Setting value sets the value attribute" );
+} );
-QUnit.test("val() with non-matching values on dropdown list", function( assert ) {
+QUnit.test( "val() with non-matching values on dropdown list", function( assert ) {
assert.expect( 3 );
- jQuery("#select5").val( "" );
- assert.equal( jQuery("#select5").val(), null, "Non-matching set on select-one" );
+ jQuery( "#select5" ).val( "" );
+ assert.equal( jQuery( "#select5" ).val(), null, "Non-matching set on select-one" );
- var select6 = jQuery("").appendTo("#form");
- jQuery(select6).val( "nothing" );
- assert.equal( jQuery(select6).val(), null, "Non-matching set (single value) on select-multiple" );
+ var select6 = jQuery( "" ).appendTo( "#form" );
+ jQuery( select6 ).val( "nothing" );
+ assert.equal( jQuery( select6 ).val(), null, "Non-matching set (single value) on select-multiple" );
- jQuery(select6).val( ["nothing1", "nothing2"] );
- assert.equal( jQuery(select6).val(), null, "Non-matching set (array of values) on select-multiple" );
+ jQuery( select6 ).val( [ "nothing1", "nothing2" ] );
+ assert.equal( jQuery( select6 ).val(), null, "Non-matching set (array of values) on select-multiple" );
select6.remove();
-});
+} );
-if ( "value" in document.createElement("meter") &&
- "value" in document.createElement("progress") ) {
+if ( "value" in document.createElement( "meter" ) &&
+ "value" in document.createElement( "progress" ) ) {
QUnit.test( "val() respects numbers without exception (Bug #9319)", function( assert ) {
assert.expect( 4 );
- var $meter = jQuery(""),
- $progress = jQuery("");
+ var $meter = jQuery( "" ),
+ $progress = jQuery( "" );
try {
assert.equal( typeof $meter.val(), "number", "meter, returns a number and does not throw exception" );
@@ -920,47 +921,47 @@ if ( "value" in document.createElement("meter") &&
assert.equal( typeof $progress.val(), "number", "progress, returns a number and does not throw exception" );
assert.equal( $progress.val(), $progress[ 0 ].value, "progress, api matches host and does not throw exception" );
- } catch( e ) {}
+ } catch ( e ) {}
$meter.remove();
$progress.remove();
- });
+ } );
}
var testVal = function( valueObj, assert ) {
assert.expect( 9 );
- jQuery("#text1").val( valueObj("test") );
- assert.equal( document.getElementById("text1").value, "test", "Check for modified (via val(String)) value of input element" );
+ jQuery( "#text1" ).val( valueObj( "test" ) );
+ assert.equal( document.getElementById( "text1" ).value, "test", "Check for modified (via val(String)) value of input element" );
- jQuery("#text1").val( valueObj( undefined ) );
- assert.equal( document.getElementById("text1").value, "", "Check for modified (via val(undefined)) value of input element" );
+ jQuery( "#text1" ).val( valueObj( undefined ) );
+ assert.equal( document.getElementById( "text1" ).value, "", "Check for modified (via val(undefined)) value of input element" );
- jQuery("#text1").val( valueObj( 67 ) );
- assert.equal( document.getElementById("text1").value, "67", "Check for modified (via val(Number)) value of input element" );
+ jQuery( "#text1" ).val( valueObj( 67 ) );
+ assert.equal( document.getElementById( "text1" ).value, "67", "Check for modified (via val(Number)) value of input element" );
- jQuery("#text1").val( valueObj( null ) );
- assert.equal( document.getElementById("text1").value, "", "Check for modified (via val(null)) value of input element" );
+ jQuery( "#text1" ).val( valueObj( null ) );
+ assert.equal( document.getElementById( "text1" ).value, "", "Check for modified (via val(null)) value of input element" );
var j,
$select = jQuery( "" ),
- $select1 = jQuery("#select1");
+ $select1 = jQuery( "#select1" );
- $select1.val( valueObj("3") );
+ $select1.val( valueObj( "3" ) );
assert.equal( $select1.val(), "3", "Check for modified (via val(String)) value of select element" );
$select1.val( valueObj( 2 ) );
assert.equal( $select1.val(), "2", "Check for modified (via val(Number)) value of select element" );
- $select1.append("");
+ $select1.append( "" );
$select1.val( valueObj( 4 ) );
assert.equal( $select1.val(), "4", "Should be possible to set the val() to a newly created option" );
// using contents will get comments regular, text, and comment nodes
- j = jQuery("#nonnodes").contents();
+ j = jQuery( "#nonnodes" ).contents();
j.val( valueObj( "asdf" ) );
assert.equal( j.val(), "asdf", "Check node,textnode,comment with val()" );
- j.removeAttr("value");
+ j.removeAttr( "value" );
$select.val( valueObj( [ "1", "2" ] ) );
assert.deepEqual( $select.val(), [ "1", "2" ], "Should set array of values" );
@@ -968,407 +969,406 @@ var testVal = function( valueObj, assert ) {
QUnit.test( "val(String/Number)", function( assert ) {
testVal( bareObj, assert );
-});
+} );
QUnit.test( "val(Function)", function( assert ) {
testVal( functionReturningObj, assert );
-});
+} );
QUnit.test( "val(Array of Numbers) (Bug #7123)", function( assert ) {
assert.expect( 4 );
- jQuery("#form").append("");
- var elements = jQuery("input[name=arrayTest]").val([ 1, 2 ]);
+ jQuery( "#form" ).append( "" );
+ var elements = jQuery( "input[name=arrayTest]" ).val( [ 1, 2 ] );
assert.ok( elements[ 0 ].checked, "First element was checked" );
assert.ok( elements[ 1 ].checked, "Second element was checked" );
assert.ok( !elements[ 2 ].checked, "Third element was unchecked" );
assert.ok( !elements[ 3 ].checked, "Fourth element remained unchecked" );
elements.remove();
-});
+} );
QUnit.test( "val(Function) with incoming value", function( assert ) {
assert.expect( 10 );
- var oldVal = jQuery("#text1").val();
+ var oldVal = jQuery( "#text1" ).val();
- jQuery("#text1").val(function( i, val ) {
+ jQuery( "#text1" ).val( function( i, val ) {
assert.equal( val, oldVal, "Make sure the incoming value is correct." );
return "test";
- });
+ } );
- assert.equal( document.getElementById("text1").value, "test", "Check for modified (via val(String)) value of input element" );
+ assert.equal( document.getElementById( "text1" ).value, "test", "Check for modified (via val(String)) value of input element" );
- oldVal = jQuery("#text1").val();
+ oldVal = jQuery( "#text1" ).val();
- jQuery("#text1").val(function( i, val ) {
+ jQuery( "#text1" ).val( function( i, val ) {
assert.equal( val, oldVal, "Make sure the incoming value is correct." );
return 67;
- });
+ } );
- assert.equal( document.getElementById("text1").value, "67", "Check for modified (via val(Number)) value of input element" );
+ assert.equal( document.getElementById( "text1" ).value, "67", "Check for modified (via val(Number)) value of input element" );
- oldVal = jQuery("#select1").val();
+ oldVal = jQuery( "#select1" ).val();
- jQuery("#select1").val(function( i, val ) {
+ jQuery( "#select1" ).val( function( i, val ) {
assert.equal( val, oldVal, "Make sure the incoming value is correct." );
return "3";
- });
+ } );
- assert.equal( jQuery("#select1").val(), "3", "Check for modified (via val(String)) value of select element" );
+ assert.equal( jQuery( "#select1" ).val(), "3", "Check for modified (via val(String)) value of select element" );
- oldVal = jQuery("#select1").val();
+ oldVal = jQuery( "#select1" ).val();
- jQuery("#select1").val(function( i, val ) {
+ jQuery( "#select1" ).val( function( i, val ) {
assert.equal( val, oldVal, "Make sure the incoming value is correct." );
return 2;
- });
+ } );
- assert.equal( jQuery("#select1").val(), "2", "Check for modified (via val(Number)) value of select element" );
+ assert.equal( jQuery( "#select1" ).val(), "2", "Check for modified (via val(Number)) value of select element" );
- jQuery("#select1").append("");
+ jQuery( "#select1" ).append( "" );
- oldVal = jQuery("#select1").val();
+ oldVal = jQuery( "#select1" ).val();
- jQuery("#select1").val(function( i, val ) {
+ jQuery( "#select1" ).val( function( i, val ) {
assert.equal( val, oldVal, "Make sure the incoming value is correct." );
return 4;
- });
+ } );
- assert.equal( jQuery("#select1").val(), "4", "Should be possible to set the val() to a newly created option" );
-});
+ assert.equal( jQuery( "#select1" ).val(), "4", "Should be possible to set the val() to a newly created option" );
+} );
// testing if a form.reset() breaks a subsequent call to a select element's .val() (in IE only)
QUnit.test( "val(select) after form.reset() (Bug #2551)", function( assert ) {
assert.expect( 3 );
- jQuery("").appendTo("#qunit-fixture");
+ jQuery( "" ).appendTo( "#qunit-fixture" );
- jQuery("#kkk").val("gf");
+ jQuery( "#kkk" ).val( "gf" );
- document["kk"].reset();
+ document[ "kk" ].reset();
- assert.equal( jQuery("#kkk")[ 0 ].value, "cf", "Check value of select after form reset." );
- assert.equal( jQuery("#kkk").val(), "cf", "Check value of select after form reset." );
+ assert.equal( jQuery( "#kkk" )[ 0 ].value, "cf", "Check value of select after form reset." );
+ assert.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
- assert.deepEqual( jQuery("#select3").val(), ["1", "2"], "Call val() on a multiple='multiple' select" );
+ assert.deepEqual( jQuery( "#select3" ).val(), [ "1", "2" ], "Call val() on a multiple='multiple' select" );
- jQuery("#kk").remove();
-});
+ jQuery( "#kk" ).remove();
+} );
var testAddClass = function( valueObj, assert ) {
assert.expect( 9 );
var pass, j, i,
- div = jQuery("#qunit-fixture div");
- div.addClass( valueObj("test") );
+ div = jQuery( "#qunit-fixture div" );
+ div.addClass( valueObj( "test" ) );
pass = true;
for ( i = 0; i < div.length; i++ ) {
- if ( !~div.get( i ).className.indexOf("test") ) {
+ if ( !~div.get( i ).className.indexOf( "test" ) ) {
pass = false;
}
}
assert.ok( pass, "Add Class" );
// using contents will get regular, text, and comment nodes
- j = jQuery("#nonnodes").contents();
- j.addClass( valueObj("asdf") );
- assert.ok( j.hasClass("asdf"), "Check node,textnode,comment for addClass" );
+ j = jQuery( "#nonnodes" ).contents();
+ j.addClass( valueObj( "asdf" ) );
+ assert.ok( j.hasClass( "asdf" ), "Check node,textnode,comment for addClass" );
- div = jQuery("");
+ div = jQuery( "" );
- div.addClass( valueObj("test") );
- assert.equal( div.attr("class"), "test", "Make sure there's no extra whitespace." );
+ div.addClass( valueObj( "test" ) );
+ assert.equal( div.attr( "class" ), "test", "Make sure there's no extra whitespace." );
div.attr( "class", " foo" );
- div.addClass( valueObj("test") );
- assert.equal( div.attr("class"), "foo test", "Make sure there's no extra whitespace." );
+ div.addClass( valueObj( "test" ) );
+ assert.equal( div.attr( "class" ), "foo test", "Make sure there's no extra whitespace." );
div.attr( "class", "foo" );
- div.addClass( valueObj("bar baz") );
- assert.equal( div.attr("class"), "foo bar baz", "Make sure there isn't too much trimming." );
+ div.addClass( valueObj( "bar baz" ) );
+ assert.equal( div.attr( "class" ), "foo bar baz", "Make sure there isn't too much trimming." );
div.removeClass();
- div.addClass( valueObj("foo") ).addClass( valueObj("foo") );
- assert.equal( div.attr("class"), "foo", "Do not add the same class twice in separate calls." );
+ div.addClass( valueObj( "foo" ) ).addClass( valueObj( "foo" ) );
+ assert.equal( div.attr( "class" ), "foo", "Do not add the same class twice in separate calls." );
- div.addClass( valueObj("fo") );
- assert.equal( div.attr("class"), "foo fo", "Adding a similar class does not get interrupted." );
- div.removeClass().addClass("wrap2");
- assert.ok( div.addClass("wrap").hasClass("wrap"), "Can add similarly named classes");
+ div.addClass( valueObj( "fo" ) );
+ assert.equal( div.attr( "class" ), "foo fo", "Adding a similar class does not get interrupted." );
+ div.removeClass().addClass( "wrap2" );
+ assert.ok( div.addClass( "wrap" ).hasClass( "wrap" ), "Can add similarly named classes" );
div.removeClass();
- div.addClass( valueObj("bar bar") );
- assert.equal( div.attr("class"), "bar", "Do not add the same class twice in the same call." );
+ div.addClass( valueObj( "bar bar" ) );
+ assert.equal( div.attr( "class" ), "bar", "Do not add the same class twice in the same call." );
};
QUnit.test( "addClass(String)", function( assert ) {
testAddClass( bareObj, assert );
-});
+} );
QUnit.test( "addClass(Function)", function( assert ) {
testAddClass( functionReturningObj, assert );
-});
+} );
QUnit.test( "addClass(Function) with incoming value", function( assert ) {
assert.expect( 52 );
var pass, i,
- div = jQuery("#qunit-fixture div"),
- old = div.map(function() {
- return jQuery(this).attr("class") || "";
- });
+ div = jQuery( "#qunit-fixture div" ),
+ old = div.map( function() {
+ return jQuery( this ).attr( "class" ) || "";
+ } );
- div.addClass(function( i, val ) {
+ div.addClass( function( i, val ) {
if ( this.id !== "_firebugConsole" ) {
assert.equal( val, old[ i ], "Make sure the incoming value is correct." );
return "test";
}
- });
+ } );
pass = true;
for ( i = 0; i < div.length; i++ ) {
- if ( div.get(i).className.indexOf("test") === -1 ) {
+ if ( div.get( i ).className.indexOf( "test" ) === -1 ) {
pass = false;
}
}
assert.ok( pass, "Add Class" );
-});
+} );
var testRemoveClass = function( valueObj, assert ) {
assert.expect( 8 );
- var $set = jQuery("#qunit-fixture div"),
- div = document.createElement("div");
+ var $set = jQuery( "#qunit-fixture div" ),
+ div = document.createElement( "div" );
- $set.addClass("test").removeClass( valueObj("test") );
+ $set.addClass( "test" ).removeClass( valueObj( "test" ) );
- assert.ok( !$set.is(".test"), "Remove Class" );
+ assert.ok( !$set.is( ".test" ), "Remove Class" );
- $set.addClass("test").addClass("foo").addClass("bar");
- $set.removeClass( valueObj("test") ).removeClass( valueObj("bar") ).removeClass( valueObj("foo") );
+ $set.addClass( "test" ).addClass( "foo" ).addClass( "bar" );
+ $set.removeClass( valueObj( "test" ) ).removeClass( valueObj( "bar" ) ).removeClass( valueObj( "foo" ) );
- assert.ok( !$set.is(".test,.bar,.foo"), "Remove multiple classes" );
+ assert.ok( !$set.is( ".test,.bar,.foo" ), "Remove multiple classes" );
// Make sure that a null value doesn't cause problems
- $set.eq( 0 ).addClass("expected").removeClass( valueObj( null ) );
- assert.ok( $set.eq( 0 ).is(".expected"), "Null value passed to removeClass" );
+ $set.eq( 0 ).addClass( "expected" ).removeClass( valueObj( null ) );
+ assert.ok( $set.eq( 0 ).is( ".expected" ), "Null value passed to removeClass" );
- $set.eq( 0 ).addClass("expected").removeClass( valueObj("") );
- assert.ok( $set.eq( 0 ).is(".expected"), "Empty string passed to removeClass" );
+ $set.eq( 0 ).addClass( "expected" ).removeClass( valueObj( "" ) );
+ assert.ok( $set.eq( 0 ).is( ".expected" ), "Empty string passed to removeClass" );
// using contents will get regular, text, and comment nodes
- $set = jQuery("#nonnodes").contents();
- $set.removeClass( valueObj("asdf") );
- assert.ok( !$set.hasClass("asdf"), "Check node,textnode,comment for removeClass" );
+ $set = jQuery( "#nonnodes" ).contents();
+ $set.removeClass( valueObj( "asdf" ) );
+ assert.ok( !$set.hasClass( "asdf" ), "Check node,textnode,comment for removeClass" );
-
- jQuery( div ).removeClass( valueObj("foo") );
- assert.strictEqual( jQuery( div ).attr("class"), undefined, "removeClass doesn't create a class attribute" );
+ jQuery( div ).removeClass( valueObj( "foo" ) );
+ assert.strictEqual( jQuery( div ).attr( "class" ), undefined, "removeClass doesn't create a class attribute" );
div.className = " test foo ";
- jQuery( div ).removeClass( valueObj("foo") );
+ jQuery( div ).removeClass( valueObj( "foo" ) );
assert.equal( div.className, "test", "Make sure remaining className is trimmed." );
div.className = " test ";
- jQuery( div ).removeClass( valueObj("test") );
+ jQuery( div ).removeClass( valueObj( "test" ) );
assert.equal( div.className, "", "Make sure there is nothing left after everything is removed." );
};
QUnit.test( "removeClass(String) - simple", function( assert ) {
testRemoveClass( bareObj, assert );
-});
+} );
QUnit.test( "removeClass(Function) - simple", function( assert ) {
testRemoveClass( functionReturningObj, assert );
-});
+} );
QUnit.test( "removeClass(Function) with incoming value", function( assert ) {
assert.expect( 52 );
- var $divs = jQuery("#qunit-fixture div").addClass("test"), old = $divs.map(function() {
- return jQuery( this ).attr("class");
- });
+ var $divs = jQuery( "#qunit-fixture div" ).addClass( "test" ), old = $divs.map( function() {
+ return jQuery( this ).attr( "class" );
+ } );
- $divs.removeClass(function( i, val ) {
+ $divs.removeClass( function( i, val ) {
if ( this.id !== "_firebugConsole" ) {
assert.equal( val, old[ i ], "Make sure the incoming value is correct." );
return "test";
}
- });
+ } );
- assert.ok( !$divs.is(".test"), "Remove Class" );
-});
+ assert.ok( !$divs.is( ".test" ), "Remove Class" );
+} );
QUnit.test( "removeClass() removes duplicates", function( assert ) {
assert.expect( 1 );
- var $div = jQuery( jQuery.parseHTML("") );
+ var $div = jQuery( jQuery.parseHTML( "" ) );
- $div.removeClass("x");
+ $div.removeClass( "x" );
- assert.ok( !$div.hasClass("x"), "Element with multiple same classes does not escape the wrath of removeClass()" );
-});
+ assert.ok( !$div.hasClass( "x" ), "Element with multiple same classes does not escape the wrath of removeClass()" );
+} );
-QUnit.test("removeClass(undefined) is a no-op", function( assert ) {
+QUnit.test( "removeClass(undefined) is a no-op", function( assert ) {
assert.expect( 1 );
- var $div = jQuery("");
+ var $div = jQuery( "" );
$div.removeClass( undefined );
- assert.ok( $div.hasClass("base") && $div.hasClass("second"), "Element still has classes after removeClass(undefined)" );
-});
+ assert.ok( $div.hasClass( "base" ) && $div.hasClass( "second" ), "Element still has classes after removeClass(undefined)" );
+} );
var testToggleClass = function( valueObj, assert ) {
assert.expect( 17 );
- var e = jQuery("#firstp");
- assert.ok( !e.is(".test"), "Assert class not present" );
- e.toggleClass( valueObj("test") );
- assert.ok( e.is(".test"), "Assert class present" );
- e.toggleClass( valueObj("test") );
- assert.ok( !e.is(".test"), "Assert class not present" );
+ var e = jQuery( "#firstp" );
+ assert.ok( !e.is( ".test" ), "Assert class not present" );
+ e.toggleClass( valueObj( "test" ) );
+ assert.ok( e.is( ".test" ), "Assert class present" );
+ e.toggleClass( valueObj( "test" ) );
+ assert.ok( !e.is( ".test" ), "Assert class not present" );
// class name with a boolean
- e.toggleClass( valueObj("test"), false );
- assert.ok( !e.is(".test"), "Assert class not present" );
- e.toggleClass( valueObj("test"), true );
- assert.ok( e.is(".test"), "Assert class present" );
- e.toggleClass( valueObj("test"), false );
- assert.ok( !e.is(".test"), "Assert class not present" );
+ e.toggleClass( valueObj( "test" ), false );
+ assert.ok( !e.is( ".test" ), "Assert class not present" );
+ e.toggleClass( valueObj( "test" ), true );
+ assert.ok( e.is( ".test" ), "Assert class present" );
+ e.toggleClass( valueObj( "test" ), false );
+ assert.ok( !e.is( ".test" ), "Assert class not present" );
// multiple class names
- e.addClass("testA testB");
- assert.ok( e.is(".testA.testB"), "Assert 2 different classes present" );
- e.toggleClass( valueObj("testB testC") );
- assert.ok( (e.is(".testA.testC") && !e.is(".testB")), "Assert 1 class added, 1 class removed, and 1 class kept" );
- e.toggleClass( valueObj("testA testC") );
- assert.ok( (!e.is(".testA") && !e.is(".testB") && !e.is(".testC")), "Assert no class present" );
+ e.addClass( "testA testB" );
+ assert.ok( e.is( ".testA.testB" ), "Assert 2 different classes present" );
+ e.toggleClass( valueObj( "testB testC" ) );
+ assert.ok( ( e.is( ".testA.testC" ) && !e.is( ".testB" ) ), "Assert 1 class added, 1 class removed, and 1 class kept" );
+ e.toggleClass( valueObj( "testA testC" ) );
+ assert.ok( ( !e.is( ".testA" ) && !e.is( ".testB" ) && !e.is( ".testC" ) ), "Assert no class present" );
// toggleClass storage
e.toggleClass( true );
assert.ok( e[ 0 ].className === "", "Assert class is empty (data was empty)" );
- e.addClass("testD testE");
- assert.ok( e.is(".testD.testE"), "Assert class present" );
+ e.addClass( "testD testE" );
+ assert.ok( e.is( ".testD.testE" ), "Assert class present" );
e.toggleClass();
- assert.ok( !e.is(".testD.testE"), "Assert class not present" );
- assert.ok( jQuery._data(e[ 0 ], "__className__") === "testD testE", "Assert data was stored" );
+ assert.ok( !e.is( ".testD.testE" ), "Assert class not present" );
+ assert.ok( jQuery._data( e[ 0 ], "__className__" ) === "testD testE", "Assert data was stored" );
e.toggleClass();
- assert.ok( e.is(".testD.testE"), "Assert class present (restored from data)" );
+ assert.ok( e.is( ".testD.testE" ), "Assert class present (restored from data)" );
e.toggleClass( false );
- assert.ok( !e.is(".testD.testE"), "Assert class not present" );
+ assert.ok( !e.is( ".testD.testE" ), "Assert class not present" );
e.toggleClass( true );
- assert.ok( e.is(".testD.testE"), "Assert class present (restored from data)" );
+ assert.ok( e.is( ".testD.testE" ), "Assert class present (restored from data)" );
e.toggleClass();
e.toggleClass( false );
e.toggleClass();
- assert.ok( e.is(".testD.testE"), "Assert class present (restored from data)" );
+ assert.ok( e.is( ".testD.testE" ), "Assert class present (restored from data)" );
// Cleanup
- e.removeClass("testD");
+ e.removeClass( "testD" );
QUnit.expectJqData( this, e[ 0 ], "__className__" );
};
QUnit.test( "toggleClass(String|boolean|undefined[, boolean])", function( assert ) {
testToggleClass( bareObj, assert );
-});
+} );
QUnit.test( "toggleClass(Function[, boolean])", function( assert ) {
testToggleClass( functionReturningObj, assert );
-});
+} );
QUnit.test( "toggleClass(Function[, boolean]) with incoming value", function( assert ) {
assert.expect( 14 );
- var e = jQuery("#firstp"),
- old = e.attr("class") || "";
+ var e = jQuery( "#firstp" ),
+ old = e.attr( "class" ) || "";
- assert.ok( !e.is(".test"), "Assert class not present" );
+ assert.ok( !e.is( ".test" ), "Assert class not present" );
- e.toggleClass(function( i, val ) {
+ e.toggleClass( function( i, val ) {
assert.equal( old, val, "Make sure the incoming value is correct." );
return "test";
- });
- assert.ok( e.is(".test"), "Assert class present" );
+ } );
+ assert.ok( e.is( ".test" ), "Assert class present" );
- old = e.attr("class");
+ old = e.attr( "class" );
- e.toggleClass(function( i, val ) {
+ e.toggleClass( function( i, val ) {
assert.equal( old, val, "Make sure the incoming value is correct." );
return "test";
- });
- assert.ok( !e.is(".test"), "Assert class not present" );
+ } );
+ assert.ok( !e.is( ".test" ), "Assert class not present" );
- old = e.attr("class") || "";
+ old = e.attr( "class" ) || "";
// class name with a boolean
- e.toggleClass(function( i, val, state ) {
+ e.toggleClass( function( i, val, state ) {
assert.equal( old, val, "Make sure the incoming value is correct." );
assert.equal( state, false, "Make sure that the state is passed in." );
return "test";
}, false );
- assert.ok( !e.is(".test"), "Assert class not present" );
+ assert.ok( !e.is( ".test" ), "Assert class not present" );
- old = e.attr("class") || "";
+ old = e.attr( "class" ) || "";
- e.toggleClass(function( i, val, state ) {
+ e.toggleClass( function( i, val, state ) {
assert.equal( old, val, "Make sure the incoming value is correct." );
assert.equal( state, true, "Make sure that the state is passed in." );
return "test";
}, true );
- assert.ok( e.is(".test"), "Assert class present" );
+ assert.ok( e.is( ".test" ), "Assert class present" );
- old = e.attr("class");
+ old = e.attr( "class" );
- e.toggleClass(function( i, val, state ) {
+ e.toggleClass( function( i, val, state ) {
assert.equal( old, val, "Make sure the incoming value is correct." );
assert.equal( state, false, "Make sure that the state is passed in." );
return "test";
}, false );
- assert.ok( !e.is(".test"), "Assert class not present" );
-});
+ assert.ok( !e.is( ".test" ), "Assert class not present" );
+} );
QUnit.test( "addClass, removeClass, hasClass", function( assert ) {
assert.expect( 17 );
- var jq = jQuery("
Hi
"), x = jq[ 0 ];
+ var jq = jQuery( "
Hi
" ), x = jq[ 0 ];
- jq.addClass("hi");
+ jq.addClass( "hi" );
assert.equal( x.className, "hi", "Check single added class" );
- jq.addClass("foo bar");
+ jq.addClass( "foo bar" );
assert.equal( x.className, "hi foo bar", "Check more added classes" );
jq.removeClass();
assert.equal( x.className, "", "Remove all classes" );
- jq.addClass("hi foo bar");
- jq.removeClass("foo");
+ jq.addClass( "hi foo bar" );
+ jq.removeClass( "foo" );
assert.equal( x.className, "hi bar", "Check removal of one class" );
- assert.ok( jq.hasClass("hi"), "Check has1" );
- assert.ok( jq.hasClass("bar"), "Check has2" );
+ assert.ok( jq.hasClass( "hi" ), "Check has1" );
+ assert.ok( jq.hasClass( "bar" ), "Check has2" );
- jq = jQuery("");
+ jq = jQuery( "" );
- assert.ok( jq.hasClass("class1"), "Check hasClass with line feed" );
- assert.ok( jq.is(".class1"), "Check is with line feed" );
- assert.ok( jq.hasClass("class2"), "Check hasClass with tab" );
- assert.ok( jq.is(".class2"), "Check is with tab" );
- assert.ok( jq.hasClass("cla.ss3"), "Check hasClass with dot" );
- assert.ok( jq.hasClass("class4"), "Check hasClass with carriage return" );
- assert.ok( jq.is(".class4"), "Check is with carriage return" );
+ assert.ok( jq.hasClass( "class1" ), "Check hasClass with line feed" );
+ assert.ok( jq.is( ".class1" ), "Check is with line feed" );
+ assert.ok( jq.hasClass( "class2" ), "Check hasClass with tab" );
+ assert.ok( jq.is( ".class2" ), "Check is with tab" );
+ assert.ok( jq.hasClass( "cla.ss3" ), "Check hasClass with dot" );
+ assert.ok( jq.hasClass( "class4" ), "Check hasClass with carriage return" );
+ assert.ok( jq.is( ".class4" ), "Check is with carriage return" );
- jq.removeClass("class2");
- assert.ok( jq.hasClass("class2") === false, "Check the class has been properly removed" );
- jq.removeClass("cla");
- assert.ok( jq.hasClass("cla.ss3"), "Check the dotted class has not been removed" );
- jq.removeClass("cla.ss3");
- assert.ok( jq.hasClass("cla.ss3") === false, "Check the dotted class has been removed" );
- jq.removeClass("class4");
- assert.ok( jq.hasClass("class4") === false, "Check the class has been properly removed" );
-});
+ jq.removeClass( "class2" );
+ assert.ok( jq.hasClass( "class2" ) === false, "Check the class has been properly removed" );
+ jq.removeClass( "cla" );
+ assert.ok( jq.hasClass( "cla.ss3" ), "Check the dotted class has not been removed" );
+ jq.removeClass( "cla.ss3" );
+ assert.ok( jq.hasClass( "cla.ss3" ) === false, "Check the dotted class has been removed" );
+ jq.removeClass( "class4" );
+ assert.ok( jq.hasClass( "class4" ) === false, "Check the class has been properly removed" );
+} );
QUnit.test( "addClass, removeClass, hasClass on many elements", function( assert ) {
assert.expect( 19 );
@@ -1411,17 +1411,17 @@ QUnit.test( "addClass, removeClass, hasClass on many elements", function( assert
assert.ok( !jQuery( "
p0
p1
p2
" ).hasClass( "hi" ),
"Did not find a class when not present" );
-});
+} );
QUnit.test( "contents().hasClass() returns correct values", function( assert ) {
assert.expect( 2 );
- var $div = jQuery("
text
"),
+ var $div = jQuery( "
text
" ),
$contents = $div.contents();
- assert.ok( $contents.hasClass("foo"), "Found 'foo' in $contents" );
- assert.ok( !$contents.hasClass("undefined"), "Did not find 'undefined' in $contents (correctly)" );
-});
+ assert.ok( $contents.hasClass( "foo" ), "Found 'foo' in $contents" );
+ assert.ok( !$contents.hasClass( "undefined" ), "Did not find 'undefined' in $contents (correctly)" );
+} );
QUnit.test( "hasClass correctly interprets non-space separators (#13835)", function( assert ) {
assert.expect( 4 );
@@ -1435,23 +1435,23 @@ QUnit.test( "hasClass correctly interprets non-space separators (#13835)", funct
},
classes = jQuery.map( map, function( separator, label ) {
return " " + separator + label + separator + " ";
- }),
+ } ),
$div = jQuery( "" );
jQuery.each( map, function( label ) {
assert.ok( $div.hasClass( label ), label.replace( "-", " " ) );
- });
-});
+ } );
+} );
QUnit.test( "coords returns correct values in IE6/IE7, see #10828", function( assert ) {
assert.expect( 1 );
var area,
- map = jQuery("");
+ map = jQuery( "" );
- area = map.html("").find("area");
- assert.equal( area.attr("coords"), "0,0,0,0", "did not retrieve coords correctly" );
-});
+ area = map.html( "" ).find( "area" );
+ assert.equal( area.attr( "coords" ), "0,0,0,0", "did not retrieve coords correctly" );
+} );
QUnit.test( "should not throw at $(option).val() (#14686)", function( assert ) {
assert.expect( 1 );
@@ -1462,12 +1462,12 @@ QUnit.test( "should not throw at $(option).val() (#14686)", function( assert ) {
} catch ( _ ) {
assert.ok( false );
}
-});
+} );
QUnit.test( "option value not trimmed when setting via parent select", function( assert ) {
assert.expect( 1 );
assert.equal( jQuery( "" ).val( "2" ).val(), "2" );
-});
+} );
QUnit.test( "Insignificant white space returned for $(option).val() (#14858)", function( assert ) {
expect ( 3 );
@@ -1480,7 +1480,7 @@ QUnit.test( "Insignificant white space returned for $(option).val() (#14858)", f
val = jQuery( "" ).val();
assert.equal( val.length, 4, "insignificant white-space returned for value" );
-});
+} );
QUnit.test( "SVG class manipulation (gh-2199)", function( assert ) {
assert.expect( 12 );
@@ -1489,7 +1489,7 @@ QUnit.test( "SVG class manipulation (gh-2199)", function( assert ) {
return document.createElementNS( "http://www.w3.org/2000/svg", nodeName );
}
- jQuery.each([
+ jQuery.each( [
"svg",
"rect",
"g"
@@ -1507,5 +1507,5 @@ QUnit.test( "SVG class manipulation (gh-2199)", function( assert ) {
elem.toggleClass( "awesome" );
assert.ok( !elem.hasClass( "awesome" ), "SVG element (" + this + ") toggles the class off" );
- });
-});
+ } );
+} );
diff --git a/test/unit/callbacks.js b/test/unit/callbacks.js
index af33174d4..c6c379ded 100644
--- a/test/unit/callbacks.js
+++ b/test/unit/callbacks.js
@@ -1,8 +1,8 @@
QUnit.module( "callbacks", {
teardown: moduleTeardown
-});
+} );
-(function() {
+( function() {
var output,
addToOutput = function( string ) {
@@ -10,9 +10,9 @@ var output,
output += string;
};
},
- outputA = addToOutput("A"),
- outputB = addToOutput("B"),
- outputC = addToOutput("C"),
+ outputA = addToOutput( "A" ),
+ outputB = addToOutput( "B" ),
+ outputC = addToOutput( "C" ),
tests = {
"": "XABC X XABCABCC X XBB X XABA X XX",
"once": "XABC X X X X X XABA X XX",
@@ -54,11 +54,11 @@ jQuery.each( tests, function( strFlags, resultString ) {
if ( this.length ) {
objectFlags[ this ] = true;
}
- });
+ } );
jQuery.each( filters, function( filterLabel ) {
- jQuery.each({
+ jQuery.each( {
"string": strFlags,
"object": objectFlags
}, function( flagsTypes, flags ) {
@@ -76,20 +76,20 @@ jQuery.each( tests, function( strFlags, resultString ) {
assert.strictEqual( cblist.locked(), false, ".locked() initially false" );
assert.strictEqual( cblist.disabled(), false, ".disabled() initially false" );
assert.strictEqual( cblist.fired(), false, ".fired() initially false" );
- cblist.add(function( str ) {
+ cblist.add( function( str ) {
output += str;
- });
+ } );
assert.strictEqual( cblist.fired(), false, ".fired() still false after .add" );
cblist.fire( "A" );
assert.strictEqual( output, "XA", "Basic binding and firing" );
assert.strictEqual( cblist.fired(), true, ".fired() detects firing" );
output = "X";
cblist.disable();
- cblist.add(function( str ) {
+ cblist.add( function( str ) {
output += str;
- });
+ } );
assert.strictEqual( output, "X", "Adding a callback after disabling" );
- cblist.fire("A");
+ cblist.fire( "A" );
assert.strictEqual( output, "X", "Firing after disabling" );
assert.strictEqual( cblist.disabled(), true, ".disabled() becomes true" );
assert.strictEqual( cblist.locked(), true, "disabling locks" );
@@ -113,20 +113,20 @@ jQuery.each( tests, function( strFlags, resultString ) {
// Basic binding and firing (context, arguments)
output = "X";
cblist = jQuery.Callbacks( flags );
- cblist.add(function() {
+ cblist.add( function() {
assert.equal( this, window, "Basic binding and firing (context)" );
output += Array.prototype.join.call( arguments, "" );
- });
+ } );
cblist.fireWith( window, [ "A", "B" ] );
assert.strictEqual( output, "XAB", "Basic binding and firing (arguments)" );
// fireWith with no arguments
output = "";
cblist = jQuery.Callbacks( flags );
- cblist.add(function() {
+ cblist.add( function() {
assert.equal( this, window, "fireWith with no arguments (context is window)" );
assert.strictEqual( arguments.length, 0, "fireWith with no arguments (no arguments)" );
- });
+ } );
cblist.fireWith();
// Basic binding, removing and firing
@@ -150,17 +150,17 @@ jQuery.each( tests, function( strFlags, resultString ) {
// Locking
output = "X";
cblist = jQuery.Callbacks( flags );
- cblist.add(function( str ) {
+ cblist.add( function( str ) {
output += str;
- });
+ } );
cblist.lock();
- cblist.add(function( str ) {
+ cblist.add( function( str ) {
output += str;
- });
- cblist.fire("A");
- cblist.add(function( str ) {
+ } );
+ cblist.fire( "A" );
+ cblist.add( function( str ) {
output += str;
- });
+ } );
assert.strictEqual( output, "X", "Lock early" );
assert.strictEqual( cblist.locked(), true, "Locking reflected in accessor" );
@@ -168,16 +168,16 @@ jQuery.each( tests, function( strFlags, resultString ) {
output = "X";
cblist = jQuery.Callbacks( flags );
cblist.add( cblist.lock );
- cblist.add(function( str ) {
+ cblist.add( function( str ) {
output += str;
- });
+ } );
cblist.fire( "A" );
assert.strictEqual( output, "XA", "Locking doesn't abort execution (gh-1990)" );
// Ordering
output = "X";
cblist = jQuery.Callbacks( flags );
- cblist.add(function() {
+ cblist.add( function() {
cblist.add( outputC );
outputA();
}, outputB );
@@ -186,7 +186,7 @@ jQuery.each( tests, function( strFlags, resultString ) {
// Add and fire again
output = "X";
- cblist.add(function() {
+ cblist.add( function() {
cblist.add( outputC );
outputA();
}, outputB );
@@ -199,23 +199,23 @@ jQuery.each( tests, function( strFlags, resultString ) {
// Multiple fire
output = "X";
cblist = jQuery.Callbacks( flags );
- cblist.add(function( str ) {
+ cblist.add( function( str ) {
output += str;
- });
- cblist.fire("A");
+ } );
+ cblist.fire( "A" );
assert.strictEqual( output, "XA", "Multiple fire (first fire)" );
output = "X";
- cblist.add(function( str ) {
+ cblist.add( function( str ) {
output += str;
- });
+ } );
assert.strictEqual( output, results.shift(), "Multiple fire (first new callback)" );
output = "X";
- cblist.fire("B");
+ cblist.fire( "B" );
assert.strictEqual( output, results.shift(), "Multiple fire (second fire)" );
output = "X";
- cblist.add(function( str ) {
+ cblist.add( function( str ) {
output += str;
- });
+ } );
assert.strictEqual( output, results.shift(), "Multiple fire (second new callback)" );
// Return false
@@ -244,12 +244,12 @@ jQuery.each( tests, function( strFlags, resultString ) {
cblist.add( handler );
cblist.fire();
assert.strictEqual( output, results.shift(), "No callback iteration" );
- });
- });
- });
-});
+ } );
+ } );
+ } );
+} );
-})();
+} )();
QUnit.test( "jQuery.Callbacks( options ) - options are copied", function( assert ) {
@@ -263,25 +263,25 @@ QUnit.test( "jQuery.Callbacks( options ) - options are copied", function( assert
fn = function() {
assert.ok( !( count++ ), "called once" );
};
- options["unique"] = false;
+ options[ "unique" ] = false;
cb.add( fn, fn );
cb.fire();
-});
+} );
QUnit.test( "jQuery.Callbacks.fireWith - arguments are copied", function( assert ) {
assert.expect( 1 );
- var cb = jQuery.Callbacks("memory"),
- args = ["hello"];
+ var cb = jQuery.Callbacks( "memory" ),
+ args = [ "hello" ];
cb.fireWith( null, args );
args[ 0 ] = "world";
- cb.add(function( hello ) {
+ cb.add( function( hello ) {
assert.strictEqual( hello, "hello", "arguments are copied internally" );
- });
-});
+ } );
+} );
QUnit.test( "jQuery.Callbacks.remove - should remove all instances", function( assert ) {
@@ -295,8 +295,8 @@ QUnit.test( "jQuery.Callbacks.remove - should remove all instances", function( a
cb.add( fn, fn, function() {
assert.ok( true, "end of test" );
- }).remove( fn ).fire();
-});
+ } ).remove( fn ).fire();
+} );
QUnit.test( "jQuery.Callbacks.has", function( assert ) {
@@ -312,36 +312,36 @@ QUnit.test( "jQuery.Callbacks.has", function( assert ) {
function getC() {
return "C";
}
- cb.add(getA, getB, getC);
+ cb.add( getA, getB, getC );
assert.strictEqual( cb.has(), true, "No arguments to .has() returns whether callback function(s) are attached or not" );
- assert.strictEqual( cb.has(getA), true, "Check if a specific callback function is in the Callbacks list" );
+ assert.strictEqual( cb.has( getA ), true, "Check if a specific callback function is in the Callbacks list" );
- cb.remove(getB);
- assert.strictEqual( cb.has(getB), false, "Remove a specific callback function and make sure its no longer there" );
- assert.strictEqual( cb.has(getA), true, "Remove a specific callback function and make sure other callback function is still there" );
+ cb.remove( getB );
+ assert.strictEqual( cb.has( getB ), false, "Remove a specific callback function and make sure its no longer there" );
+ assert.strictEqual( cb.has( getA ), true, "Remove a specific callback function and make sure other callback function is still there" );
cb.empty();
assert.strictEqual( cb.has(), false, "Empty list and make sure there are no callback function(s)" );
- assert.strictEqual( cb.has(getA), false, "Check for a specific function in an empty() list" );
+ assert.strictEqual( cb.has( getA ), false, "Check for a specific function in an empty() list" );
- cb.add(getA, getB, function(){
+ cb.add( getA, getB, function() {
assert.strictEqual( cb.has(), true, "Check if list has callback function(s) from within a callback function" );
- assert.strictEqual( cb.has(getA), true, "Check if list has a specific callback from within a callback function" );
- }).fire();
+ assert.strictEqual( cb.has( getA ), true, "Check if list has a specific callback from within a callback function" );
+ } ).fire();
assert.strictEqual( cb.has(), true, "Callbacks list has callback function(s) after firing" );
cb.disable();
assert.strictEqual( cb.has(), false, "disabled() list has no callback functions (returns false)" );
- assert.strictEqual( cb.has(getA), false, "Check for a specific function in a disabled() list" );
+ assert.strictEqual( cb.has( getA ), false, "Check for a specific function in a disabled() list" );
- cb = jQuery.Callbacks("unique");
- cb.add(getA);
- cb.add(getA);
+ cb = jQuery.Callbacks( "unique" );
+ cb.add( getA );
+ cb.add( getA );
assert.strictEqual( cb.has(), true, "Check if unique list has callback function(s) attached" );
cb.lock();
assert.strictEqual( cb.has(), false, "locked() list is empty and returns false" );
-});
+} );
QUnit.test( "jQuery.Callbacks() - adding a string doesn't cause a stack overflow", function( assert ) {
@@ -350,7 +350,7 @@ QUnit.test( "jQuery.Callbacks() - adding a string doesn't cause a stack overflow
jQuery.Callbacks().add( "hello world" );
assert.ok( true, "no stack overflow" );
-});
+} );
QUnit.test( "jQuery.Callbacks() - disabled callback doesn't fire (gh-1790)", function( assert ) {
@@ -365,4 +365,4 @@ QUnit.test( "jQuery.Callbacks() - disabled callback doesn't fire (gh-1790)", fun
cb.add( shot );
cb.fire();
assert.ok( !fired, "Disabled callback function didn't fire" );
-});
+} );
diff --git a/test/unit/core.js b/test/unit/core.js
index 1a6cf5e3c..d9ec725c9 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -1,7 +1,7 @@
-QUnit.module("core", { teardown: moduleTeardown });
+QUnit.module( "core", { teardown: moduleTeardown } );
-QUnit.test("Basic requirements", function( assert ) {
- assert.expect(7);
+QUnit.test( "Basic requirements", function( assert ) {
+ assert.expect( 7 );
assert.ok( Array.prototype.push, "Array.push()" );
assert.ok( Function.prototype.apply, "Function.apply()" );
assert.ok( document.getElementById, "getElementById" );
@@ -9,15 +9,15 @@ QUnit.test("Basic requirements", function( assert ) {
assert.ok( RegExp, "RegExp" );
assert.ok( jQuery, "jQuery" );
assert.ok( $, "$" );
-});
+} );
-QUnit.test("jQuery()", function( assert ) {
+QUnit.test( "jQuery()", function( assert ) {
var elem, i,
- obj = jQuery("div"),
- code = jQuery(""),
- img = jQuery(""),
- div = jQuery(""),
+ obj = jQuery( "div" ),
+ code = jQuery( "" ),
+ img = jQuery( "" ),
+ div = jQuery( "" ),
exec = false,
expected = 23,
attrObj = {
@@ -30,19 +30,19 @@ QUnit.test("jQuery()", function( assert ) {
// few here but beware of modular builds where these methods may be excluded.
if ( jQuery.fn.click ) {
expected++;
- attrObj["click"] = function() { ok( exec, "Click executed." ); };
+ attrObj[ "click" ] = function() { ok( exec, "Click executed." ); };
}
if ( jQuery.fn.width ) {
expected++;
- attrObj["width"] = 10;
+ attrObj[ "width" ] = 10;
}
if ( jQuery.fn.offset ) {
expected++;
- attrObj["offset"] = { "top": 1, "left": 1 };
+ attrObj[ "offset" ] = { "top": 1, "left": 1 };
}
if ( jQuery.fn.css ) {
expected += 2;
- attrObj["css"] = { "paddingLeft": 1, "paddingRight": 1 };
+ attrObj[ "css" ] = { "paddingLeft": 1, "paddingRight": 1 };
}
if ( jQuery.fn.attr ) {
expected++;
@@ -53,10 +53,10 @@ QUnit.test("jQuery()", function( assert ) {
// Basic constructor's behavior
assert.equal( jQuery().length, 0, "jQuery() === jQuery([])" );
- assert.equal( jQuery(undefined).length, 0, "jQuery(undefined) === jQuery([])" );
- assert.equal( jQuery(null).length, 0, "jQuery(null) === jQuery([])" );
- assert.equal( jQuery("").length, 0, "jQuery('') === jQuery([])" );
- assert.deepEqual( jQuery(obj).get(), obj.get(), "jQuery(jQueryObj) == jQueryObj" );
+ assert.equal( jQuery( undefined ).length, 0, "jQuery(undefined) === jQuery([])" );
+ assert.equal( jQuery( null ).length, 0, "jQuery(null) === jQuery([])" );
+ assert.equal( jQuery( "" ).length, 0, "jQuery('') === jQuery([])" );
+ assert.deepEqual( jQuery( obj ).get(), obj.get(), "jQuery(jQueryObj) == jQueryObj" );
// Invalid #id goes to Sizzle which will throw an error (gh-1682)
try {
@@ -66,7 +66,7 @@ QUnit.test("jQuery()", function( assert ) {
}
// can actually yield more than one, when iframes are included, the window is an array as well
- assert.equal( jQuery(window).length, 1, "Correct number of elements generated for jQuery(window)" );
+ assert.equal( jQuery( window ).length, 1, "Correct number of elements generated for jQuery(window)" );
/*
// disabled since this test was doing nothing. i tried to fix it but i'm not sure
@@ -95,84 +95,84 @@ QUnit.test("jQuery()", function( assert ) {
assert.equal( div.length, 4, "Correct number of elements generated for div hr code b" );
assert.equal( div.parent().length, 0, "Make sure that the generated HTML has no parent." );
- assert.equal( jQuery([1,2,3]).get(1), 2, "Test passing an array to the factory" );
+ assert.equal( jQuery( [ 1,2,3 ] ).get( 1 ), 2, "Test passing an array to the factory" );
- assert.equal( jQuery(document.body).get(0), jQuery("body").get(0), "Test passing an html node to the factory" );
+ assert.equal( jQuery( document.body ).get( 0 ), jQuery( "body" ).get( 0 ), "Test passing an html node to the factory" );
- elem = jQuery(" hello")[0];
+ elem = jQuery( " hello" )[ 0 ];
assert.equal( elem.nodeName.toLowerCase(), "em", "leading space" );
- elem = jQuery("\n\nworld")[0];
+ elem = jQuery( "\n\nworld" )[ 0 ];
assert.equal( elem.nodeName.toLowerCase(), "em", "leading newlines" );
- elem = jQuery("", attrObj );
+ elem = jQuery( "", attrObj );
if ( jQuery.fn.width ) {
- assert.equal( elem[0].style.width, "10px", "jQuery() quick setter width");
+ assert.equal( elem[ 0 ].style.width, "10px", "jQuery() quick setter width" );
}
if ( jQuery.fn.offset ) {
- assert.equal( elem[0].style.top, "1px", "jQuery() quick setter offset");
+ assert.equal( elem[ 0 ].style.top, "1px", "jQuery() quick setter offset" );
}
if ( jQuery.fn.css ) {
- assert.equal( elem[0].style.paddingLeft, "1px", "jQuery quick setter css");
- assert.equal( elem[0].style.paddingRight, "1px", "jQuery quick setter css");
+ assert.equal( elem[ 0 ].style.paddingLeft, "1px", "jQuery quick setter css" );
+ assert.equal( elem[ 0 ].style.paddingRight, "1px", "jQuery quick setter css" );
}
if ( jQuery.fn.attr ) {
- assert.equal( elem[0].getAttribute("desired"), "very", "jQuery quick setter attr");
+ assert.equal( elem[ 0 ].getAttribute( "desired" ), "very", "jQuery quick setter attr" );
}
- assert.equal( elem[0].childNodes.length, 1, "jQuery quick setter text");
- assert.equal( elem[0].firstChild.nodeValue, "test", "jQuery quick setter text");
- assert.equal( elem[0].className, "test2", "jQuery() quick setter class");
- assert.equal( elem[0].id, "test3", "jQuery() quick setter id");
+ assert.equal( elem[ 0 ].childNodes.length, 1, "jQuery quick setter text" );
+ assert.equal( elem[ 0 ].firstChild.nodeValue, "test", "jQuery quick setter text" );
+ assert.equal( elem[ 0 ].className, "test2", "jQuery() quick setter class" );
+ assert.equal( elem[ 0 ].id, "test3", "jQuery() quick setter id" );
exec = true;
- elem.trigger("click");
+ elem.trigger( "click" );
// manually clean up detached elements
elem.remove();
for ( i = 0; i < 3; ++i ) {
- elem = jQuery("");
+ elem = jQuery( "" );
}
- assert.equal( elem[0].defaultValue, "TEST", "Ensure cached nodes are cloned properly (Bug #6655)" );
+ assert.equal( elem[ 0 ].defaultValue, "TEST", "Ensure cached nodes are cloned properly (Bug #6655)" );
elem = jQuery( "", {} );
assert.strictEqual( elem[ 0 ].ownerDocument, document,
"Empty attributes object is not interpreted as a document (trac-8950)" );
-});
+} );
-QUnit.test("jQuery(selector, context)", function( assert ) {
- assert.expect(3);
- assert.deepEqual( jQuery("div p", "#qunit-fixture").get(), q("sndp", "en", "sap"), "Basic selector with string as context" );
- assert.deepEqual( jQuery("div p", q("qunit-fixture")[0]).get(), q("sndp", "en", "sap"), "Basic selector with element as context" );
- assert.deepEqual( jQuery("div p", jQuery("#qunit-fixture")).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" );
-});
+QUnit.test( "jQuery(selector, context)", function( assert ) {
+ assert.expect( 3 );
+ assert.deepEqual( jQuery( "div p", "#qunit-fixture" ).get(), q( "sndp", "en", "sap" ), "Basic selector with string as context" );
+ assert.deepEqual( jQuery( "div p", q( "qunit-fixture" )[ 0 ] ).get(), q( "sndp", "en", "sap" ), "Basic selector with element as context" );
+ assert.deepEqual( jQuery( "div p", jQuery( "#qunit-fixture" ) ).get(), q( "sndp", "en", "sap" ), "Basic selector with jQuery object as context" );
+} );
QUnit.test( "globalEval", function( assert ) {
assert.expect( 3 );
- Globals.register("globalEvalTest");
+ Globals.register( "globalEvalTest" );
- jQuery.globalEval("globalEvalTest = 1;");
+ jQuery.globalEval( "globalEvalTest = 1;" );
assert.equal( window.globalEvalTest, 1, "Test variable assignments are global" );
- jQuery.globalEval("var globalEvalTest = 2;");
+ jQuery.globalEval( "var globalEvalTest = 2;" );
assert.equal( window.globalEvalTest, 2, "Test variable declarations are global" );
- jQuery.globalEval("this.globalEvalTest = 3;");
+ jQuery.globalEval( "this.globalEvalTest = 3;" );
assert.equal( window.globalEvalTest, 3, "Test context (this) is the window object" );
-});
+} );
QUnit.test( "globalEval with 'use strict'", function( assert ) {
assert.expect( 1 );
- Globals.register("strictEvalTest");
+ Globals.register( "strictEvalTest" );
- jQuery.globalEval("'use strict'; var strictEvalTest = 1;");
+ jQuery.globalEval( "'use strict'; var strictEvalTest = 1;" );
assert.equal( window.strictEvalTest, 1, "Test variable declarations are global (strict mode)" );
-});
+} );
QUnit.test( "globalEval execution after script injection (#7862)", function( assert ) {
assert.expect( 1 );
@@ -185,41 +185,41 @@ QUnit.test( "globalEval execution after script injection (#7862)", function( ass
now = jQuery.now();
document.body.appendChild( script );
- jQuery.globalEval( "var strictEvalTest = " + jQuery.now() + ";");
+ jQuery.globalEval( "var strictEvalTest = " + jQuery.now() + ";" );
assert.ok( window.strictEvalTest - now < 500, "Code executed synchronously" );
-});
+} );
// This is not run in AMD mode
if ( jQuery.noConflict ) {
- QUnit.test("noConflict", function( assert ) {
- assert.expect(7);
+ QUnit.test( "noConflict", function( assert ) {
+ assert.expect( 7 );
var $$ = jQuery;
assert.strictEqual( jQuery, jQuery.noConflict(), "noConflict returned the jQuery object" );
- assert.strictEqual( window["jQuery"], $$, "Make sure jQuery wasn't touched." );
- assert.strictEqual( window["$"], original$, "Make sure $ was reverted." );
+ assert.strictEqual( window[ "jQuery" ], $$, "Make sure jQuery wasn't touched." );
+ assert.strictEqual( window[ "$" ], original$, "Make sure $ was reverted." );
jQuery = $ = $$;
- assert.strictEqual( jQuery.noConflict(true), $$, "noConflict returned the jQuery object" );
- assert.strictEqual( window["jQuery"], originaljQuery, "Make sure jQuery was reverted." );
- assert.strictEqual( window["$"], original$, "Make sure $ was reverted." );
- assert.ok( $$().pushStack([]), "Make sure that jQuery still works." );
+ assert.strictEqual( jQuery.noConflict( true ), $$, "noConflict returned the jQuery object" );
+ assert.strictEqual( window[ "jQuery" ], originaljQuery, "Make sure jQuery was reverted." );
+ assert.strictEqual( window[ "$" ], original$, "Make sure $ was reverted." );
+ assert.ok( $$().pushStack( [] ), "Make sure that jQuery still works." );
- window["jQuery"] = jQuery = $$;
- });
+ window[ "jQuery" ] = jQuery = $$;
+ } );
}
-QUnit.test("trim", function( assert ) {
- assert.expect(13);
+QUnit.test( "trim", function( assert ) {
+ assert.expect( 13 );
- var nbsp = String.fromCharCode(160);
+ var nbsp = String.fromCharCode( 160 );
- assert.equal( jQuery.trim("hello "), "hello", "trailing space" );
- assert.equal( jQuery.trim(" hello"), "hello", "leading space" );
- assert.equal( jQuery.trim(" hello "), "hello", "space on both sides" );
- assert.equal( jQuery.trim(" " + nbsp + "hello " + nbsp + " "), "hello", " " );
+ assert.equal( jQuery.trim( "hello " ), "hello", "trailing space" );
+ assert.equal( jQuery.trim( " hello" ), "hello", "leading space" );
+ assert.equal( jQuery.trim( " hello " ), "hello", "space on both sides" );
+ assert.equal( jQuery.trim( " " + nbsp + "hello " + nbsp + " " ), "hello", " " );
assert.equal( jQuery.trim(), "", "Nothing in." );
assert.equal( jQuery.trim( undefined ), "", "Undefined" );
@@ -227,88 +227,88 @@ QUnit.test("trim", function( assert ) {
assert.equal( jQuery.trim( 5 ), "5", "Number" );
assert.equal( jQuery.trim( false ), "false", "Boolean" );
- assert.equal( jQuery.trim(" "), "", "space should be trimmed" );
- assert.equal( jQuery.trim("ipad\xA0"), "ipad", "nbsp should be trimmed" );
- assert.equal( jQuery.trim("\uFEFF"), "", "zwsp should be trimmed" );
- assert.equal( jQuery.trim("\uFEFF \xA0! | \uFEFF"), "! |", "leading/trailing should be trimmed" );
-});
+ assert.equal( jQuery.trim( " " ), "", "space should be trimmed" );
+ assert.equal( jQuery.trim( "ipad\xA0" ), "ipad", "nbsp should be trimmed" );
+ assert.equal( jQuery.trim( "\uFEFF" ), "", "zwsp should be trimmed" );
+ assert.equal( jQuery.trim( "\uFEFF \xA0! | \uFEFF" ), "! |", "leading/trailing should be trimmed" );
+} );
-QUnit.test("type", function( assert ) {
+QUnit.test( "type", function( assert ) {
assert.expect( 28 );
- assert.equal( jQuery.type(null), "null", "null" );
- assert.equal( jQuery.type(undefined), "undefined", "undefined" );
- assert.equal( jQuery.type(true), "boolean", "Boolean" );
- assert.equal( jQuery.type(false), "boolean", "Boolean" );
- assert.equal( jQuery.type(Boolean(true)), "boolean", "Boolean" );
- assert.equal( jQuery.type(0), "number", "Number" );
- assert.equal( jQuery.type(1), "number", "Number" );
- assert.equal( jQuery.type(Number(1)), "number", "Number" );
- assert.equal( jQuery.type(""), "string", "String" );
- assert.equal( jQuery.type("a"), "string", "String" );
- assert.equal( jQuery.type(String("a")), "string", "String" );
- assert.equal( jQuery.type({}), "object", "Object" );
- assert.equal( jQuery.type(/foo/), "regexp", "RegExp" );
- assert.equal( jQuery.type(new RegExp("asdf")), "regexp", "RegExp" );
- assert.equal( jQuery.type([1]), "array", "Array" );
- assert.equal( jQuery.type(new Date()), "date", "Date" );
- assert.equal( jQuery.type(new Function("return;")), "function", "Function" );
- assert.equal( jQuery.type(function(){}), "function", "Function" );
- assert.equal( jQuery.type(new Error()), "error", "Error" );
- assert.equal( jQuery.type(window), "object", "Window" );
- assert.equal( jQuery.type(document), "object", "Document" );
- assert.equal( jQuery.type(document.body), "object", "Element" );
- assert.equal( jQuery.type(document.createTextNode("foo")), "object", "TextNode" );
- assert.equal( jQuery.type(document.getElementsByTagName("*")), "object", "NodeList" );
+ assert.equal( jQuery.type( null ), "null", "null" );
+ assert.equal( jQuery.type( undefined ), "undefined", "undefined" );
+ assert.equal( jQuery.type( true ), "boolean", "Boolean" );
+ assert.equal( jQuery.type( false ), "boolean", "Boolean" );
+ assert.equal( jQuery.type( Boolean( true ) ), "boolean", "Boolean" );
+ assert.equal( jQuery.type( 0 ), "number", "Number" );
+ assert.equal( jQuery.type( 1 ), "number", "Number" );
+ assert.equal( jQuery.type( Number( 1 ) ), "number", "Number" );
+ assert.equal( jQuery.type( "" ), "string", "String" );
+ assert.equal( jQuery.type( "a" ), "string", "String" );
+ assert.equal( jQuery.type( String( "a" ) ), "string", "String" );
+ assert.equal( jQuery.type( {} ), "object", "Object" );
+ assert.equal( jQuery.type( /foo/ ), "regexp", "RegExp" );
+ assert.equal( jQuery.type( new RegExp( "asdf" ) ), "regexp", "RegExp" );
+ assert.equal( jQuery.type( [ 1 ] ), "array", "Array" );
+ assert.equal( jQuery.type( new Date() ), "date", "Date" );
+ assert.equal( jQuery.type( new Function( "return;" ) ), "function", "Function" );
+ assert.equal( jQuery.type( function() {} ), "function", "Function" );
+ assert.equal( jQuery.type( new Error() ), "error", "Error" );
+ assert.equal( jQuery.type( window ), "object", "Window" );
+ assert.equal( jQuery.type( document ), "object", "Document" );
+ assert.equal( jQuery.type( document.body ), "object", "Element" );
+ assert.equal( jQuery.type( document.createTextNode( "foo" ) ), "object", "TextNode" );
+ assert.equal( jQuery.type( document.getElementsByTagName( "*" ) ), "object", "NodeList" );
// Avoid Lint complaints
var MyString = String,
MyNumber = Number,
MyBoolean = Boolean,
MyObject = Object;
- assert.equal( jQuery.type(new MyBoolean(true)), "boolean", "Boolean" );
- assert.equal( jQuery.type(new MyNumber(1)), "number", "Number" );
- assert.equal( jQuery.type(new MyString("a")), "string", "String" );
- assert.equal( jQuery.type(new MyObject()), "object", "Object" );
-});
+ assert.equal( jQuery.type( new MyBoolean( true ) ), "boolean", "Boolean" );
+ assert.equal( jQuery.type( new MyNumber( 1 ) ), "number", "Number" );
+ assert.equal( jQuery.type( new MyString( "a" ) ), "string", "String" );
+ assert.equal( jQuery.type( new MyObject() ), "object", "Object" );
+} );
-QUnit.asyncTest("isPlainObject", function( assert ) {
- assert.expect(15);
+QUnit.asyncTest( "isPlainObject", function( assert ) {
+ assert.expect( 15 );
var pass, iframe, doc,
fn = function() {};
// The use case that we want to match
- assert.ok( jQuery.isPlainObject({}), "{}" );
+ assert.ok( jQuery.isPlainObject( {} ), "{}" );
// Not objects shouldn't be matched
- assert.ok( !jQuery.isPlainObject(""), "string" );
- assert.ok( !jQuery.isPlainObject(0) && !jQuery.isPlainObject(1), "number" );
- assert.ok( !jQuery.isPlainObject(true) && !jQuery.isPlainObject(false), "boolean" );
- assert.ok( !jQuery.isPlainObject(null), "null" );
- assert.ok( !jQuery.isPlainObject(undefined), "undefined" );
+ assert.ok( !jQuery.isPlainObject( "" ), "string" );
+ assert.ok( !jQuery.isPlainObject( 0 ) && !jQuery.isPlainObject( 1 ), "number" );
+ assert.ok( !jQuery.isPlainObject( true ) && !jQuery.isPlainObject( false ), "boolean" );
+ assert.ok( !jQuery.isPlainObject( null ), "null" );
+ assert.ok( !jQuery.isPlainObject( undefined ), "undefined" );
// Arrays shouldn't be matched
- assert.ok( !jQuery.isPlainObject([]), "array" );
+ assert.ok( !jQuery.isPlainObject( [] ), "array" );
// Instantiated objects shouldn't be matched
- assert.ok( !jQuery.isPlainObject(new Date()), "new Date" );
+ assert.ok( !jQuery.isPlainObject( new Date() ), "new Date" );
// Functions shouldn't be matched
- assert.ok( !jQuery.isPlainObject(fn), "fn" );
+ assert.ok( !jQuery.isPlainObject( fn ), "fn" );
// Again, instantiated objects shouldn't be matched
- assert.ok( !jQuery.isPlainObject(new fn()), "new fn (no methods)" );
+ assert.ok( !jQuery.isPlainObject( new fn() ), "new fn (no methods)" );
// Makes the function a little more realistic
// (and harder to detect, incidentally)
- fn.prototype["someMethod"] = function(){};
+ fn.prototype[ "someMethod" ] = function() {};
// Again, instantiated objects shouldn't be matched
- assert.ok( !jQuery.isPlainObject(new fn()), "new fn" );
+ assert.ok( !jQuery.isPlainObject( new fn() ), "new fn" );
// DOM Element
- assert.ok( !jQuery.isPlainObject( document.createElement("div") ), "DOM Element" );
+ assert.ok( !jQuery.isPlainObject( document.createElement( "div" ) ), "DOM Element" );
// Window
assert.ok( !jQuery.isPlainObject( window ), "window" );
@@ -321,27 +321,27 @@ QUnit.asyncTest("isPlainObject", function( assert ) {
assert.ok( pass, "Does not throw exceptions on host objects" );
// Objects from other windows should be matched
- Globals.register("iframeDone");
+ Globals.register( "iframeDone" );
window.iframeDone = function( otherObject, detail ) {
window.iframeDone = undefined;
iframe.parentNode.removeChild( iframe );
- assert.ok( jQuery.isPlainObject(new otherObject()), "new otherObject" + ( detail ? " - " + detail : "" ) );
+ assert.ok( jQuery.isPlainObject( new otherObject() ), "new otherObject" + ( detail ? " - " + detail : "" ) );
QUnit.start();
};
try {
- iframe = jQuery("#qunit-fixture")[0].appendChild( document.createElement("iframe") );
+ iframe = jQuery( "#qunit-fixture" )[ 0 ].appendChild( document.createElement( "iframe" ) );
doc = iframe.contentDocument || iframe.contentWindow.document;
doc.open();
- doc.write("");
+ doc.write( "" );
doc.close();
- } catch(e) {
+ } catch ( e ) {
window.iframeDone( Object, "iframes not supported" );
}
-});
+} );
-QUnit.test("isFunction", function( assert ) {
- assert.expect(19);
+QUnit.test( "isFunction", function( assert ) {
+ assert.expect( 19 );
var mystr, myarr, myfunction, fn, obj, nodes, first, input, a;
@@ -353,31 +353,31 @@ QUnit.test("isFunction", function( assert ) {
assert.ok( !jQuery.isFunction( 0 ), "0 Value" );
// Check built-ins
- assert.ok( jQuery.isFunction(String), "String Function("+String+")" );
- assert.ok( jQuery.isFunction(Array), "Array Function("+Array+")" );
- assert.ok( jQuery.isFunction(Object), "Object Function("+Object+")" );
- assert.ok( jQuery.isFunction(Function), "Function Function("+Function+")" );
+ assert.ok( jQuery.isFunction( String ), "String Function(" + String + ")" );
+ assert.ok( jQuery.isFunction( Array ), "Array Function(" + Array + ")" );
+ assert.ok( jQuery.isFunction( Object ), "Object Function(" + Object + ")" );
+ assert.ok( jQuery.isFunction( Function ), "Function Function(" + Function + ")" );
// When stringified, this could be misinterpreted
mystr = "function";
- assert.ok( !jQuery.isFunction(mystr), "Function String" );
+ assert.ok( !jQuery.isFunction( mystr ), "Function String" );
// When stringified, this could be misinterpreted
myarr = [ "function" ];
- assert.ok( !jQuery.isFunction(myarr), "Function Array" );
+ assert.ok( !jQuery.isFunction( myarr ), "Function Array" );
// When stringified, this could be misinterpreted
myfunction = { "function": "test" };
- assert.ok( !jQuery.isFunction(myfunction), "Function Object" );
+ assert.ok( !jQuery.isFunction( myfunction ), "Function Object" );
// Make sure normal functions still work
- fn = function(){};
- assert.ok( jQuery.isFunction(fn), "Normal Function" );
+ fn = function() {};
+ assert.ok( jQuery.isFunction( fn ), "Normal Function" );
- obj = document.createElement("object");
+ obj = document.createElement( "object" );
// Firefox says this is a function
- assert.ok( !jQuery.isFunction(obj), "Object Element" );
+ assert.ok( !jQuery.isFunction( obj ), "Object Element" );
// Since 1.3, this isn't supported (#2968)
//ok( jQuery.isFunction(obj.getAttribute), "getAttribute Function" );
@@ -385,14 +385,14 @@ QUnit.test("isFunction", function( assert ) {
nodes = document.body.childNodes;
// Safari says this is a function
- assert.ok( !jQuery.isFunction(nodes), "childNodes Property" );
+ assert.ok( !jQuery.isFunction( nodes ), "childNodes Property" );
first = document.body.firstChild;
// Normal elements are reported ok everywhere
- assert.ok( !jQuery.isFunction(first), "A normal DOM Element" );
+ assert.ok( !jQuery.isFunction( first ), "A normal DOM Element" );
- input = document.createElement("input");
+ input = document.createElement( "input" );
input.type = "text";
document.body.appendChild( input );
@@ -401,30 +401,30 @@ QUnit.test("isFunction", function( assert ) {
document.body.removeChild( input );
- a = document.createElement("a");
+ a = document.createElement( "a" );
a.href = "some-function";
document.body.appendChild( a );
// This serializes with the word 'function' in it
- assert.ok( !jQuery.isFunction(a), "Anchor Element" );
+ assert.ok( !jQuery.isFunction( a ), "Anchor Element" );
document.body.removeChild( a );
// Recursive function calls have lengths and array-like properties
- function callme(callback){
- function fn(response){
- callback(response);
+ function callme( callback ) {
+ function fn( response ) {
+ callback( response );
}
- assert.ok( jQuery.isFunction(fn), "Recursive Function Call" );
+ assert.ok( jQuery.isFunction( fn ), "Recursive Function Call" );
- fn({ some: "data" });
+ fn( { some: "data" } );
}
- callme(function(){
- callme(function(){});
- });
-});
+ callme( function() {
+ callme( function() {} );
+ } );
+} );
QUnit.test( "isNumeric", function( assert ) {
assert.expect( 38 );
@@ -473,345 +473,349 @@ QUnit.test( "isNumeric", function( assert ) {
assert.equal( t( {} ), false, "Empty object" );
assert.equal( t( [] ), false, "Empty array" );
assert.equal( t( [ 42 ] ), false, "Array with one number" );
- assert.equal( t( function(){} ), false, "Instance of a function" );
+ assert.equal( t( function() {} ), false, "Instance of a function" );
assert.equal( t( new Date() ), false, "Instance of a Date" );
-});
+} );
-QUnit.test("isXMLDoc - HTML", function( assert ) {
- assert.expect(4);
+QUnit.test( "isXMLDoc - HTML", function( assert ) {
+ assert.expect( 4 );
assert.ok( !jQuery.isXMLDoc( document ), "HTML document" );
assert.ok( !jQuery.isXMLDoc( document.documentElement ), "HTML documentElement" );
assert.ok( !jQuery.isXMLDoc( document.body ), "HTML Body Element" );
var body,
- iframe = document.createElement("iframe");
+ iframe = document.createElement( "iframe" );
document.body.appendChild( iframe );
try {
- body = jQuery(iframe).contents()[0];
+ body = jQuery( iframe ).contents()[ 0 ];
try {
assert.ok( !jQuery.isXMLDoc( body ), "Iframe body element" );
- } catch(e) {
+ } catch ( e ) {
assert.ok( false, "Iframe body element exception" );
}
- } catch(e) {
+ } catch ( e ) {
assert.ok( true, "Iframe body element - iframe not working correctly" );
}
document.body.removeChild( iframe );
-});
+} );
-QUnit.test("XSS via location.hash", function( assert ) {
- assert.expect(1);
+QUnit.test( "XSS via location.hash", function( assert ) {
+ assert.expect( 1 );
QUnit.stop();
- jQuery["_check9521"] = function(x){
+ jQuery[ "_check9521" ] = function( x ) {
assert.ok( x, "script called from #id-like selector with inline handler" );
- jQuery("#check9521").remove();
- delete jQuery["_check9521"];
+ jQuery( "#check9521" ).remove();
+ delete jQuery[ "_check9521" ];
QUnit.start();
};
try {
- // This throws an error because it's processed like an id
- jQuery( "#" ).appendTo("#qunit-fixture");
- } catch (err) {
- jQuery["_check9521"](true);
- }
-});
-QUnit.test("isXMLDoc - XML", function( assert ) {
- assert.expect(3);
+ // This throws an error because it's processed like an id
+ jQuery( "#" ).appendTo( "#qunit-fixture" );
+ } catch ( err ) {
+ jQuery[ "_check9521" ]( true );
+ }
+} );
+
+QUnit.test( "isXMLDoc - XML", function( assert ) {
+ assert.expect( 3 );
var xml = createDashboardXML();
assert.ok( jQuery.isXMLDoc( xml ), "XML document" );
assert.ok( jQuery.isXMLDoc( xml.documentElement ), "XML documentElement" );
- assert.ok( jQuery.isXMLDoc( jQuery("tab", xml)[0] ), "XML Tab Element" );
-});
+ assert.ok( jQuery.isXMLDoc( jQuery( "tab", xml )[ 0 ] ), "XML Tab Element" );
+} );
-QUnit.test("isWindow", function( assert ) {
+QUnit.test( "isWindow", function( assert ) {
assert.expect( 14 );
- assert.ok( jQuery.isWindow(window), "window" );
- assert.ok( jQuery.isWindow(document.getElementsByTagName("iframe")[0].contentWindow), "iframe.contentWindow" );
+ assert.ok( jQuery.isWindow( window ), "window" );
+ assert.ok( jQuery.isWindow( document.getElementsByTagName( "iframe" )[ 0 ].contentWindow ), "iframe.contentWindow" );
assert.ok( !jQuery.isWindow(), "empty" );
- assert.ok( !jQuery.isWindow(null), "null" );
- assert.ok( !jQuery.isWindow(undefined), "undefined" );
- assert.ok( !jQuery.isWindow(document), "document" );
- assert.ok( !jQuery.isWindow(document.documentElement), "documentElement" );
- assert.ok( !jQuery.isWindow(""), "string" );
- assert.ok( !jQuery.isWindow(1), "number" );
- assert.ok( !jQuery.isWindow(true), "boolean" );
- assert.ok( !jQuery.isWindow({}), "object" );
- assert.ok( !jQuery.isWindow({ setInterval: function(){} }), "fake window" );
- assert.ok( !jQuery.isWindow(/window/), "regexp" );
- assert.ok( !jQuery.isWindow(function(){}), "function" );
-});
+ assert.ok( !jQuery.isWindow( null ), "null" );
+ assert.ok( !jQuery.isWindow( undefined ), "undefined" );
+ assert.ok( !jQuery.isWindow( document ), "document" );
+ assert.ok( !jQuery.isWindow( document.documentElement ), "documentElement" );
+ assert.ok( !jQuery.isWindow( "" ), "string" );
+ assert.ok( !jQuery.isWindow( 1 ), "number" );
+ assert.ok( !jQuery.isWindow( true ), "boolean" );
+ assert.ok( !jQuery.isWindow( {} ), "object" );
+ assert.ok( !jQuery.isWindow( { setInterval: function() {} } ), "fake window" );
+ assert.ok( !jQuery.isWindow( /window/ ), "regexp" );
+ assert.ok( !jQuery.isWindow( function() {} ), "function" );
+} );
-QUnit.test("jQuery('html')", function( assert ) {
+QUnit.test( "jQuery('html')", function( assert ) {
assert.expect( 18 );
var s, div, j;
- jQuery["foo"] = false;
- s = jQuery("")[0];
+ jQuery[ "foo" ] = false;
+ s = jQuery( "" )[ 0 ];
assert.ok( s, "Creating a script" );
- assert.ok( !jQuery["foo"], "Make sure the script wasn't executed prematurely" );
- jQuery("body").append("");
- assert.ok( jQuery["foo"], "Executing a scripts contents in the right context" );
+ assert.ok( !jQuery[ "foo" ], "Make sure the script wasn't executed prematurely" );
+ jQuery( "body" ).append( "" );
+ assert.ok( jQuery[ "foo" ], "Executing a scripts contents in the right context" );
// Test multi-line HTML
- div = jQuery("
\r\nsome text\n
some p
\nmore text\r\n
")[0];
+ div = jQuery( "
\r\nsome text\n
some p
\nmore text\r\n
" )[ 0 ];
assert.equal( div.nodeName.toUpperCase(), "DIV", "Make sure we're getting a div." );
assert.equal( div.firstChild.nodeType, 3, "Text node." );
assert.equal( div.lastChild.nodeType, 3, "Text node." );
- assert.equal( div.childNodes[1].nodeType, 1, "Paragraph." );
- assert.equal( div.childNodes[1].firstChild.nodeType, 3, "Paragraph text." );
+ assert.equal( div.childNodes[ 1 ].nodeType, 1, "Paragraph." );
+ assert.equal( div.childNodes[ 1 ].firstChild.nodeType, 3, "Paragraph text." );
- assert.ok( jQuery("")[0], "Creating a link" );
+ assert.ok( jQuery( "" )[ 0 ], "Creating a link" );
- assert.ok( !jQuery("")[0].parentNode, "Create a script" );
+ assert.ok( !jQuery( "" )[ 0 ].parentNode, "Create a script" );
- assert.ok( jQuery("").attr("type", "hidden"), "Create an input and set the type." );
+ assert.ok( jQuery( "" ).attr( "type", "hidden" ), "Create an input and set the type." );
- j = jQuery("hi there ");
+ j = jQuery( "hi there " );
assert.ok( j.length >= 2, "Check node,textnode,comment creation (some browsers delete comments)" );
- assert.ok( !jQuery("")[0].selected, "Make sure that options are auto-selected #2050" );
+ assert.ok( !jQuery( "" )[ 0 ].selected, "Make sure that options are auto-selected #2050" );
- assert.ok( jQuery("")[0], "Create a div with closing tag." );
- assert.ok( jQuery("
")[0], "Create a table with closing tag." );
+ assert.ok( jQuery( "" )[ 0 ], "Create a div with closing tag." );
+ assert.ok( jQuery( "
" )[ 0 ], "Create a table with closing tag." );
assert.equal( jQuery( "element[attribute='']" ).length, 0,
"When html is within brackets, do not recognize as html." );
+
//equal( jQuery( "element[attribute=]" ).length, 0,
// "When html is within brackets, do not recognize as html." );
assert.equal( jQuery( "element:not()" ).length, 0,
"When html is within parens, do not recognize as html." );
assert.equal( jQuery( "\\
" ).length, 0, "Ignore escaped html characters" );
-});
+} );
-QUnit.test("jQuery(tag-hyphenated elements) gh-1987", function( assert ) {
+QUnit.test( "jQuery(tag-hyphenated elements) gh-1987", function( assert ) {
assert.expect( 17 );
- jQuery.each( "thead tbody tfoot colgroup caption tr th td".split(" "), function( i, name ) {
- var j = jQuery("<" + name + "-d>" + name + "-d>");
- assert.ok( j[0], "Create a tag-hyphenated elements" );
- assert.ok( jQuery.nodeName(j[0], name.toUpperCase() + "-D"), "Tag-hyphenated element has expected node name" );
- });
+ jQuery.each( "thead tbody tfoot colgroup caption tr th td".split( " " ), function( i, name ) {
+ var j = jQuery( "<" + name + "-d>" + name + "-d>" );
+ assert.ok( j[ 0 ], "Create a tag-hyphenated elements" );
+ assert.ok( jQuery.nodeName( j[ 0 ], name.toUpperCase() + "-D" ), "Tag-hyphenated element has expected node name" );
+ } );
- var j = jQuery("");
- assert.ok( jQuery.nodeName(j[0], "TR-MULTIPLE-HYPHENS"), "Element with multiple hyphens in its tag has expected node name" );
-});
+ var j = jQuery( "" );
+ assert.ok( jQuery.nodeName( j[ 0 ], "TR-MULTIPLE-HYPHENS" ), "Element with multiple hyphens in its tag has expected node name" );
+} );
-QUnit.test("jQuery('massive html #7990')", function( assert ) {
+QUnit.test( "jQuery('massive html #7990')", function( assert ) {
assert.expect( 3 );
var i,
li = "
very very very very large html string
",
- html = ["
"];
+ html = [ "
" ];
for ( i = 0; i < 30000; i += 1 ) {
- html[html.length] = li;
+ html[ html.length ] = li;
}
- html[html.length] = "
" )[ 1 ].parentNode.nodeType, 11,
"parentNode should be documentFragment for wrapMap (variable in manipulation module) elements too" );
- assert.ok( jQuery.parseHTML("<#if>
This is a test.
<#/if>") || true, "Garbage input should not cause error" );
-});
+ assert.ok( jQuery.parseHTML( "<#if>
" );
+ div.show().appendTo( "#qunit-fixture" );
+ assert.equal( div.css( "display" ), "none",
"A shown-while-detached div can be hidden by the CSS cascade" );
- div = jQuery("
").appendTo("#qunit-fixture");
- x = div.find("div");
+ div = jQuery( "
" ).appendTo( "#qunit-fixture" );
+ x = div.find( "div" );
assert.strictEqual( x.toggle().css( "display" ), "none", "is hidden" );
assert.strictEqual( x.toggle().css( "display" ), "block", "is visible" );
@@ -667,103 +667,104 @@ QUnit.test("toggle()", function( assert ) {
};
x.toggle( name === "show" );
jQuery.fn.hide = oldHide;
-});
+} );
-QUnit.test("hide hidden elements (bug #7141)", function( assert ) {
- assert.expect(3);
+QUnit.test( "hide hidden elements (bug #7141)", function( assert ) {
+ assert.expect( 3 );
- var div = jQuery("").appendTo("#qunit-fixture");
- assert.equal( div.css("display"), "none", "Element is hidden by default" );
+ var div = jQuery( "" ).appendTo( "#qunit-fixture" );
+ assert.equal( div.css( "display" ), "none", "Element is hidden by default" );
div.hide();
- assert.ok( !jQuery._data(div, "olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
+ assert.ok( !jQuery._data( div, "olddisplay" ), "olddisplay is undefined after hiding an already-hidden element" );
div.show();
- assert.equal( div.css("display"), "block", "Show a double-hidden element" );
+ assert.equal( div.css( "display" ), "block", "Show a double-hidden element" );
div.remove();
-});
+} );
-QUnit.test("jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", function( assert ) {
- assert.expect(4);
+QUnit.test( "jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", function( assert ) {
+ assert.expect( 4 );
- var $checkedtest = jQuery("#checkedtest");
- jQuery.css($checkedtest[0], "height");
+ var $checkedtest = jQuery( "#checkedtest" );
+ jQuery.css( $checkedtest[ 0 ], "height" );
- assert.ok( jQuery("input[type='radio']", $checkedtest).first().attr("checked"), "Check first radio still checked." );
- assert.ok( !jQuery("input[type='radio']", $checkedtest).last().attr("checked"), "Check last radio still NOT checked." );
- assert.ok( jQuery("input[type='checkbox']", $checkedtest).first().attr("checked"), "Check first checkbox still checked." );
- assert.ok( !jQuery("input[type='checkbox']", $checkedtest).last().attr("checked"), "Check last checkbox still NOT checked." );
-});
+ assert.ok( jQuery( "input[type='radio']", $checkedtest ).first().attr( "checked" ), "Check first radio still checked." );
+ assert.ok( !jQuery( "input[type='radio']", $checkedtest ).last().attr( "checked" ), "Check last radio still NOT checked." );
+ assert.ok( jQuery( "input[type='checkbox']", $checkedtest ).first().attr( "checked" ), "Check first checkbox still checked." );
+ assert.ok( !jQuery( "input[type='checkbox']", $checkedtest ).last().attr( "checked" ), "Check last checkbox still NOT checked." );
+} );
-QUnit.test("internal ref to elem.runtimeStyle (bug #7608)", function( assert ) {
- assert.expect(1);
+QUnit.test( "internal ref to elem.runtimeStyle (bug #7608)", function( assert ) {
+ assert.expect( 1 );
var result = true;
try {
- jQuery("#foo").css( { "width": "0%" } ).css("width");
- } catch (e) {
+ jQuery( "#foo" ).css( { "width": "0%" } ).css( "width" );
+ } catch ( e ) {
result = false;
}
assert.ok( result, "elem.runtimeStyle does not throw exception" );
-});
+} );
-QUnit.test("marginRight computed style (bug #3333)", function( assert ) {
- assert.expect(1);
+QUnit.test( "marginRight computed style (bug #3333)", function( assert ) {
+ assert.expect( 1 );
- var $div = jQuery("#foo");
- $div.css({
+ var $div = jQuery( "#foo" );
+ $div.css( {
"width": "1px",
"marginRight": 0
- });
+ } );
- assert.equal($div.css("marginRight"), "0px", "marginRight correctly calculated with a width and display block");
-});
+ assert.equal( $div.css( "marginRight" ), "0px", "marginRight correctly calculated with a width and display block" );
+} );
-QUnit.test("box model properties incorrectly returning % instead of px, see #10639 and #12088", function( assert ) {
+QUnit.test( "box model properties incorrectly returning % instead of px, see #10639 and #12088", function( assert ) {
assert.expect( 2 );
- var container = jQuery("").width( 400 ).appendTo("#qunit-fixture"),
- el = jQuery("").css({ "width": "50%", "marginRight": "50%" }).appendTo( container ),
- el2 = jQuery("").css({ "width": "50%", "minWidth": "300px", "marginLeft": "25%" }).appendTo( container );
+ var container = jQuery( "" ).width( 400 ).appendTo( "#qunit-fixture" ),
+ el = jQuery( "" ).css( { "width": "50%", "marginRight": "50%" } ).appendTo( container ),
+ el2 = jQuery( "" ).css( { "width": "50%", "minWidth": "300px", "marginLeft": "25%" } ).appendTo( container );
- assert.equal( el.css("marginRight"), "200px", "css('marginRight') returning % instead of px, see #10639" );
- assert.equal( el2.css("marginLeft"), "100px", "css('marginLeft') returning incorrect pixel value, see #12088" );
-});
+ assert.equal( el.css( "marginRight" ), "200px", "css('marginRight') returning % instead of px, see #10639" );
+ assert.equal( el2.css( "marginLeft" ), "100px", "css('marginLeft') returning incorrect pixel value, see #12088" );
+} );
-QUnit.test("jQuery.cssProps behavior, (bug #8402)", function( assert ) {
+QUnit.test( "jQuery.cssProps behavior, (bug #8402)", function( assert ) {
assert.expect( 2 );
- var div = jQuery( "
" ).appendTo(document.body).css({
+ var div = jQuery( "
" ).appendTo( document.body ).css( {
"position": "absolute",
"top": 0,
"left": 10
- });
+ } );
jQuery.cssProps.top = "left";
- assert.equal( div.css("top"), "10px", "the fixed property is used when accessing the computed style");
- div.css("top", "100px");
- assert.equal( div[0].style.left, "100px", "the fixed property is used when setting the style");
+ assert.equal( div.css( "top" ), "10px", "the fixed property is used when accessing the computed style" );
+ div.css( "top", "100px" );
+ assert.equal( div[ 0 ].style.left, "100px", "the fixed property is used when setting the style" );
+
// cleanup jQuery.cssProps
jQuery.cssProps.top = undefined;
-});
+} );
-QUnit.test("widows & orphans #8936", function( assert ) {
+QUnit.test( "widows & orphans #8936", function( assert ) {
- var $p = jQuery("
").appendTo("#qunit-fixture");
+ var $p = jQuery( "
" ).appendTo( "#qunit-fixture" );
assert.expect( 2 );
- $p.css({
+ $p.css( {
"widows": 3,
"orphans": 3
- });
+ } );
- assert.equal( $p.css( "widows" ) || jQuery.style( $p[0], "widows" ), 3, "widows correctly set to 3" );
- assert.equal( $p.css( "orphans" ) || jQuery.style( $p[0], "orphans" ), 3, "orphans correctly set to 3" );
+ assert.equal( $p.css( "widows" ) || jQuery.style( $p[ 0 ], "widows" ), 3, "widows correctly set to 3" );
+ assert.equal( $p.css( "orphans" ) || jQuery.style( $p[ 0 ], "orphans" ), 3, "orphans correctly set to 3" );
$p.remove();
-});
+} );
-QUnit.test("can't get css for disconnected in IE<9, see #10254 and #8388", function( assert ) {
+QUnit.test( "can't get css for disconnected in IE<9, see #10254 and #8388", function( assert ) {
assert.expect( 2 );
var span, div;
@@ -772,9 +773,9 @@ QUnit.test("can't get css for disconnected in IE<9, see #10254 and #8388", funct
div = jQuery( "
" ).css( "top", 10 );
assert.equal( div.css( "top" ), "10px", "can't get top in IE<9, see #8388" );
-});
+} );
-QUnit.test("can't get background-position in IE<9, see #10796", function( assert ) {
+QUnit.test( "can't get background-position in IE<9, see #10796", function( assert ) {
var div = jQuery( "" ).appendTo( "#qunit-fixture" ),
units = [
"0 0",
@@ -791,29 +792,30 @@ QUnit.test("can't get background-position in IE<9, see #10796", function( assert
assert.expect( l );
- for( ; i < l; i++ ) {
+ for ( ; i < l; i++ ) {
div.css( "background-position", units [ i ] );
assert.ok( div.css( "background-position" ), "can't get background-position in IE<9, see #10796" );
}
-});
+} );
if ( jQuery.fn.offset ) {
- QUnit.test("percentage properties for left and top should be transformed to pixels, see #9505", function( assert ) {
+ QUnit.test( "percentage properties for left and top should be transformed to pixels, see #9505", function( assert ) {
assert.expect( 2 );
- var parent = jQuery("").appendTo( "#qunit-fixture" ),
- div = jQuery("").appendTo( parent );
+ var parent = jQuery( "" ).appendTo( "#qunit-fixture" ),
+ div = jQuery( "" ).appendTo( parent );
- assert.equal( div.css("top"), "100px", "position properties not transformed to pixels, see #9505" );
- assert.equal( div.css("left"), "100px", "position properties not transformed to pixels, see #9505" );
- });
+ assert.equal( div.css( "top" ), "100px", "position properties not transformed to pixels, see #9505" );
+ assert.equal( div.css( "left" ), "100px", "position properties not transformed to pixels, see #9505" );
+ } );
}
-QUnit.test("Do not append px (#9548, #12990)", function( assert ) {
+QUnit.test( "Do not append px (#9548, #12990)", function( assert ) {
assert.expect( 2 );
- var $div = jQuery("
").appendTo("#qunit-fixture");
+ var $div = jQuery( "
" ).appendTo( "#qunit-fixture" );
$div.css( "fill-opacity", 1 );
+
// Support: Android 2.3 (no support for fill-opacity)
if ( $div.css( "fill-opacity" ) ) {
assert.equal( $div.css( "fill-opacity" ), 1, "Do not append px to 'fill-opacity'" );
@@ -822,25 +824,25 @@ QUnit.test("Do not append px (#9548, #12990)", function( assert ) {
}
$div.css( "column-count", 1 );
- if ( $div.css("column-count") ) {
- assert.equal( $div.css("column-count"), 1, "Do not append px to 'column-count'" );
+ if ( $div.css( "column-count" ) ) {
+ assert.equal( $div.css( "column-count" ), 1, "Do not append px to 'column-count'" );
} else {
assert.ok( true, "No support for column-count CSS property" );
}
-});
+} );
-QUnit.test("css('width') and css('height') should respect box-sizing, see #11004", function( assert ) {
+QUnit.test( "css('width') and css('height') should respect box-sizing, see #11004", function( assert ) {
assert.expect( 4 );
// Support: Android 2.3 (-webkit-box-sizing).
- var el_dis = jQuery("
test
"),
- el = el_dis.clone().appendTo("#qunit-fixture");
+ var el_dis = jQuery( "
test
" ),
+ el = el_dis.clone().appendTo( "#qunit-fixture" );
- assert.equal( el.css("width"), el.css("width", el.css("width")).css("width"), "css('width') is not respecting box-sizing, see #11004");
- assert.equal( el_dis.css("width"), el_dis.css("width", el_dis.css("width")).css("width"), "css('width') is not respecting box-sizing for disconnected element, see #11004");
- assert.equal( el.css("height"), el.css("height", el.css("height")).css("height"), "css('height') is not respecting box-sizing, see #11004");
- assert.equal( el_dis.css("height"), el_dis.css("height", el_dis.css("height")).css("height"), "css('height') is not respecting box-sizing for disconnected element, see #11004");
-});
+ assert.equal( el.css( "width" ), el.css( "width", el.css( "width" ) ).css( "width" ), "css('width') is not respecting box-sizing, see #11004" );
+ assert.equal( el_dis.css( "width" ), el_dis.css( "width", el_dis.css( "width" ) ).css( "width" ), "css('width') is not respecting box-sizing for disconnected element, see #11004" );
+ assert.equal( el.css( "height" ), el.css( "height", el.css( "height" ) ).css( "height" ), "css('height') is not respecting box-sizing, see #11004" );
+ assert.equal( el_dis.css( "height" ), el_dis.css( "height", el_dis.css( "height" ) ).css( "height" ), "css('height') is not respecting box-sizing for disconnected element, see #11004" );
+} );
testIframeWithCallback(
"css('width') should work correctly before document ready (#14084)",
@@ -857,7 +859,7 @@ testIframeWithCallback(
div = document.createElement( "div" );
div.style.width = "3.3px";
qunitFixture.appendChild( div );
- supportsFractionalGBCR = div.getBoundingClientRect().width.toFixed(1) === "3.3";
+ supportsFractionalGBCR = div.getBoundingClientRect().width.toFixed( 1 ) === "3.3";
qunitFixture.removeChild( div );
QUnit.test( "css('width') and css('height') should return fractional values for nodes in the document", function( assert ) {
@@ -896,23 +898,23 @@ testIframeWithCallback(
} );
} )();
-QUnit.test("certain css values of 'normal' should be convertable to a number, see #8627", function( assert ) {
+QUnit.test( "certain css values of 'normal' should be convertable to a number, see #8627", function( assert ) {
expect ( 3 );
- var el = jQuery("
test
").appendTo("#qunit-fixture");
+ var el = jQuery( "
test
" ).appendTo( "#qunit-fixture" );
- assert.ok( jQuery.isNumeric( parseFloat( el.css("letterSpacing") ) ), "css('letterSpacing') not convertable to number, see #8627" );
- assert.ok( jQuery.isNumeric( parseFloat( el.css("fontWeight") ) ), "css('fontWeight') not convertable to number, see #8627" );
+ assert.ok( jQuery.isNumeric( parseFloat( el.css( "letterSpacing" ) ) ), "css('letterSpacing') not convertable to number, see #8627" );
+ assert.ok( jQuery.isNumeric( parseFloat( el.css( "fontWeight" ) ) ), "css('fontWeight') not convertable to number, see #8627" );
assert.equal( typeof el.css( "fontWeight" ), "string", ".css() returns a string" );
-});
+} );
// only run this test in IE9
if ( document.documentMode === 9 ) {
QUnit.test( ".css('filter') returns a string in IE9, see #12537", function( assert ) {
assert.expect( 1 );
- assert.equal( jQuery("").css("filter"), "progid:DXImageTransform.Microsoft.gradient(startColorstr=#FFFFFF, endColorstr=#ECECEC)", "IE9 returns the correct value from css('filter')." );
- });
+ assert.equal( jQuery( "" ).css( "filter" ), "progid:DXImageTransform.Microsoft.gradient(startColorstr=#FFFFFF, endColorstr=#ECECEC)", "IE9 returns the correct value from css('filter')." );
+ } );
}
QUnit.test( "cssHooks - expand", function( assert ) {
@@ -920,7 +922,7 @@ QUnit.test( "cssHooks - expand", function( assert ) {
var result,
properties = {
margin: [ "marginTop", "marginRight", "marginBottom", "marginLeft" ],
- borderWidth: [ "borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"],
+ borderWidth: [ "borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth" ],
padding: [ "paddingTop", "paddingRight", "paddingBottom", "paddingLeft" ]
};
@@ -929,70 +931,70 @@ QUnit.test( "cssHooks - expand", function( assert ) {
expected = {};
jQuery.each( keys, function( _, key ) {
expected[ key ] = 10;
- });
+ } );
result = hook.expand( 10 );
assert.deepEqual( result, expected, property + " expands properly with a number" );
jQuery.each( keys, function( _, key ) {
expected[ key ] = "10px";
- });
+ } );
result = hook.expand( "10px" );
assert.deepEqual( result, expected, property + " expands properly with '10px'" );
- expected[ keys[1] ] = expected[ keys[3] ] = "20px";
+ expected[ keys[ 1 ] ] = expected[ keys[ 3 ] ] = "20px";
result = hook.expand( "10px 20px" );
assert.deepEqual( result, expected, property + " expands properly with '10px 20px'" );
- expected[ keys[2] ] = "30px";
+ expected[ keys[ 2 ] ] = "30px";
result = hook.expand( "10px 20px 30px" );
assert.deepEqual( result, expected, property + " expands properly with '10px 20px 30px'" );
- expected[ keys[3] ] = "40px";
+ expected[ keys[ 3 ] ] = "40px";
result = hook.expand( "10px 20px 30px 40px" );
assert.deepEqual( result, expected, property + " expands properly with '10px 20px 30px 40px'" );
- });
+ } );
-});
+} );
QUnit.test( "css opacity consistency across browsers (#12685)", function( assert ) {
assert.expect( 4 );
var el,
- fixture = jQuery("#qunit-fixture");
+ fixture = jQuery( "#qunit-fixture" );
// Append style element
- jQuery("").appendTo( fixture );
+ jQuery( "" ).appendTo( fixture );
- el = jQuery("").appendTo(fixture);
+ el = jQuery( "" ).appendTo( fixture );
- assert.equal( Math.round( el.css("opacity") * 100 ), 10, "opacity from style sheet (filter:alpha with spaces)" );
- el.removeClass("opacityWithSpaces_t12685").addClass("opacityNoSpaces_t12685");
- assert.equal( Math.round( el.css("opacity") * 100 ), 20, "opacity from style sheet (filter:alpha without spaces)" );
+ assert.equal( Math.round( el.css( "opacity" ) * 100 ), 10, "opacity from style sheet (filter:alpha with spaces)" );
+ el.removeClass( "opacityWithSpaces_t12685" ).addClass( "opacityNoSpaces_t12685" );
+ assert.equal( Math.round( el.css( "opacity" ) * 100 ), 20, "opacity from style sheet (filter:alpha without spaces)" );
el.css( "opacity", 0.3 );
- assert.equal( Math.round( el.css("opacity") * 100 ), 30, "override opacity" );
+ assert.equal( Math.round( el.css( "opacity" ) * 100 ), 30, "override opacity" );
el.css( "opacity", "" );
- assert.equal( Math.round( el.css("opacity") * 100 ), 20, "remove opacity override" );
-});
+ assert.equal( Math.round( el.css( "opacity" ) * 100 ), 20, "remove opacity override" );
+} );
QUnit.test( ":visible/:hidden selectors", function( assert ) {
assert.expect( 17 );
var $div, $table, $a;
- assert.ok( jQuery("#nothiddendiv").is(":visible"), "Modifying CSS display: Assert element is visible" );
- jQuery("#nothiddendiv").css({ display: "none" });
- assert.ok( !jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is hidden" );
- jQuery("#nothiddendiv").css({ "display": "block" });
- assert.ok( jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is visible");
- assert.ok( !jQuery(window).is(":visible"), "Calling is(':visible') on window does not throw an exception (#10267).");
- assert.ok( !jQuery(document).is(":visible"), "Calling is(':visible') on document does not throw an exception (#10267).");
+ assert.ok( jQuery( "#nothiddendiv" ).is( ":visible" ), "Modifying CSS display: Assert element is visible" );
+ jQuery( "#nothiddendiv" ).css( { display: "none" } );
+ assert.ok( !jQuery( "#nothiddendiv" ).is( ":visible" ), "Modified CSS display: Assert element is hidden" );
+ jQuery( "#nothiddendiv" ).css( { "display": "block" } );
+ assert.ok( jQuery( "#nothiddendiv" ).is( ":visible" ), "Modified CSS display: Assert element is visible" );
+ assert.ok( !jQuery( window ).is( ":visible" ), "Calling is(':visible') on window does not throw an exception (#10267)." );
+ assert.ok( !jQuery( document ).is( ":visible" ), "Calling is(':visible') on document does not throw an exception (#10267)." );
- assert.ok( jQuery("#nothiddendiv").is(":visible"), "Modifying CSS display: Assert element is visible");
- jQuery("#nothiddendiv").css("display", "none");
- assert.ok( !jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is hidden");
- jQuery("#nothiddendiv").css("display", "block");
- assert.ok( jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is visible");
+ assert.ok( jQuery( "#nothiddendiv" ).is( ":visible" ), "Modifying CSS display: Assert element is visible" );
+ jQuery( "#nothiddendiv" ).css( "display", "none" );
+ assert.ok( !jQuery( "#nothiddendiv" ).is( ":visible" ), "Modified CSS display: Assert element is hidden" );
+ jQuery( "#nothiddendiv" ).css( "display", "block" );
+ assert.ok( jQuery( "#nothiddendiv" ).is( ":visible" ), "Modified CSS display: Assert element is visible" );
assert.ok( jQuery( "#siblingspan" ).is( ":visible" ), "Span with no content is visible" );
$div = jQuery( "
");
- assert.equal(jQuery("#table td:visible").length, 1, "hidden cell is not perceived as visible (#4512). Works on table elements");
- $table.css("display", "none").html("
cell
cell
");
- assert.equal(jQuery("#table td:visible").length, 0, "hidden cell children not perceived as visible (#4512)");
+ $table = jQuery( "#table" );
+ $table.html( "
cell
cell
" );
+ assert.equal( jQuery( "#table td:visible" ).length, 1, "hidden cell is not perceived as visible (#4512). Works on table elements" );
+ $table.css( "display", "none" ).html( "