test("jQuery.attrFix/jQuery.propFix integrity test", function() {
expect(2);
-
+
// This must be maintained and equal jQuery.attrFix when appropriate
// Ensure that accidental or erroneous property
// overwrites don't occur
equals( jQuery("<div value='t'></div>").attr("value"), "t", "Check setting custom attr named 'value' on a div" );
equals( jQuery("#form").attr("blah", "blah").attr("blah"), "blah", "Set non-existant attribute on a form" );
equals( jQuery("#foo").attr("height"), undefined, "Non existent height attribute should return undefined" );
-
+
// [7472] & [3113] (form contains an input with name="action" or name="id")
var extras = jQuery("<input name='id' name='name' /><input id='target' name='target' />").appendTo("#testForm");
equals( jQuery("#form").attr("action","newformaction").attr("action"), "newformaction", "Check that action attribute was changed" );
// Bug #3685 (form contains input with name="name")
equals( jQuery("#testForm").attr("name"), undefined, "Retrieving name does not retrieve input with name=name" );
extras.remove();
-
+
equals( jQuery("#text1").attr("maxlength"), "30", "Check for maxlength attribute" );
equals( jQuery("#text1").attr("maxLength"), "30", "Check for maxLength attribute" );
equals( jQuery("#area1").attr("maxLength"), "30", "Check for maxLength attribute" );
commentNode = document.createComment("some comment"),
textNode = document.createTextNode("some text"),
obj = {};
-
+
jQuery.each( [commentNode, textNode, attributeNode], function( i, elem ) {
var $elem = jQuery( elem );
$elem.attr( "nonexisting", "foo" );
j.removeAttr("name");
QUnit.reset();
-
+
// Type
var type = jQuery("#check2").attr("type");
var thrown = false;
equals( jQuery("#foo").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute" );
equals( jQuery("#form").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute on a form" );
equals( jQuery("#fx-test-group").attr("height", "3px").removeAttr("height").css("height"), "1px", "Removing height attribute has no effect on height set with style attribute" );
-
+
jQuery("#check1").removeAttr("checked").prop("checked", true).removeAttr("checked");
equals( document.getElementById("check1").checked, false, "removeAttr sets boolean properties to false" );
jQuery("#text1").prop("readOnly", true).removeAttr("readonly");
var $button = jQuery("<button value='foobar'>text</button>").insertAfter("#button");
equals( $button.val(), "foobar", "Value retrieval on a button does not return innerHTML" );
equals( $button.val("baz").html(), "text", "Setting the value does not change innerHTML" );
-
+
equals( jQuery("<option/>").val("test").attr("value"), "test", "Setting value sets the value attribute" );
});
-if ( "value" in document.createElement("meter") &&
+if ( "value" in document.createElement("meter") &&
"value" in document.createElement("progress") ) {
test("val() respects numbers without exception (Bug #9319)", function() {
same( jQuery("#select3").val(), ["1", "2"], "Call val() on a multiple=\"multiple\" select" );
jQuery("#kk").remove();
-});
+});
var testAddClass = function(valueObj) {
expect(9);
div.attr("class", "foo");
div.addClass( valueObj("bar baz") );
equals( div.attr("class"), "foo bar baz", "Make sure there isn't too much trimming." );
-
+
div.removeClass();
div.addClass( valueObj("foo") ).addClass( valueObj("foo") )
equal( div.attr("class"), "foo", "Do not add the same class twice in separate calls." );
});
test("addClass(Function) with incoming value", function() {
- expect(45);
+ expect(48);
var div = jQuery("div"), old = div.map(function(){
return jQuery(this).attr("class") || "";
});
-
+
div.addClass(function(i, val) {
if ( this.id !== "_firebugConsole") {
equals( val, old[i], "Make sure the incoming value is correct." );
});
test("removeClass(Function) with incoming value", function() {
- expect(45);
+ expect(48);
var $divs = jQuery("div").addClass("test"), old = $divs.map(function(){
return jQuery(this).attr("class");
test("contents().hasClass() returns correct values", function() {
expect(2);
- var $div = jQuery("<div><span class='foo'></span><!-- comment -->text</div>"),
+ var $div = jQuery("<div><span class='foo'></span><!-- comment -->text</div>"),
$contents = $div.contents();
ok( $contents.hasClass("foo"), "Found 'foo' in $contents" );
test("find(node|jQuery object)", function() {
expect( 11 );
-
+
var $foo = jQuery("#foo"),
$blog = jQuery(".blogTest"),
$first = jQuery("#first"),
ok( $foo.find( $two ).is(".blogTest"), "Find returns only nodes within #foo" );
ok( $fooTwo.find( $blog ).is(".blogTest"), "Blog is part of the collection, but also within foo" );
ok( $fooTwo.find( $blog[0] ).is(".blogTest"), "Blog is part of the collection, but also within foo(node)" );
-
+
equals( $two.find( $foo ).length, 0, "Foo is not in two elements" );
equals( $two.find( $foo[0] ).length, 0, "Foo is not in two elements(node)" );
equals( $two.find( $first ).length, 0, "first is in the collection and not within two" );
equals( $two.find( $first ).length, 0, "first is in the collection and not within two(node)" );
-
+
});
test("is(String|undefined)", function() {
ok( !jQuery("#foo").is(""), "Expected false for an invalid expression - \"\"" );
ok( !jQuery("#foo").is(undefined), "Expected false for an invalid expression - undefined" );
ok( !jQuery("#foo").is({ plain: "object" }), "Check passing invalid object" );
-
+
// test is() with comma-seperated expressions
ok( jQuery("#en").is("[lang=\"en\"],[lang=\"de\"]"), "Comma-seperated; Check for lang attribute: Expect en or de" );
ok( jQuery("#en").is("[lang=\"de\"],[lang=\"en\"]"), "Comma-seperated; Check for lang attribute: Expect en or de" );
ok( !jQuery("#radio1").is( jQuery("input:checked") ), "Check for pseudoclass: Expected not checked" );
ok( jQuery("#foo").is( jQuery("div:has(p)") ), "Check for child: Expected a child 'p' element" );
ok( !jQuery("#foo").is( jQuery("div:has(ul)") ), "Check for child: Did not expect 'ul' element" );
-
+
// Some raw elements
ok( jQuery("#form").is( jQuery("form")[0] ), "Check for element: A form is a form" );
ok( !jQuery("#form").is( jQuery("div")[0] ), "Check for element: A form is not a div" );
expect( 2 );
equal( jQuery("#text2").index(), 2, "Returns the index of a child amongst its siblings" );
-
+
equal( jQuery("<div/>").index(), -1, "Node without parent returns -1" );
});
same( jQuery("#form input").filter(":checked").get(), q("radio2", "check1"), "filter(String)" );
same( jQuery("p").filter("#ap, #sndp").get(), q("ap", "sndp"), "filter('String, String')" );
same( jQuery("p").filter("#ap,#sndp").get(), q("ap", "sndp"), "filter('String,String')" );
-
+
same( jQuery("p").filter(null).get(), [], "filter(null) should return an empty jQuery object");
same( jQuery("p").filter(undefined).get(), [], "filter(undefined) should return an empty jQuery object");
same( jQuery("p").filter(0).get(), [], "filter(0) should return an empty jQuery object");
test("add(String, Context)", function() {
expect(6);
-
+
deepEqual( jQuery( "#firstp" ).add( "#ap" ).get(), q( "firstp", "ap" ), "Add selector to selector " );
deepEqual( jQuery( document.getElementById("firstp") ).add( "#ap" ).get(), q( "firstp", "ap" ), "Add gEBId to selector" );
deepEqual( jQuery( document.getElementById("firstp") ).add( document.getElementById("ap") ).get(), q( "firstp", "ap" ), "Add gEBId to gEBId" );