Remove conditional that prevents attr from working on non-Element nodes. Fixes #7451.
[jquery.git] / test / unit / attributes.js
index a483195..2d0a0d6 100644 (file)
@@ -4,7 +4,7 @@ var bareObj = function(value) { return value; };
 var functionReturningObj = function(value) { return (function() { return value; }); };
 
 test("attr(String)", function() {
-       expect(30);
+       expect(31);
 
        // This one sometimes fails randomly ?!
        equals( jQuery('#text1').attr('value'), "Test", 'Check for value attribute' );
@@ -65,6 +65,8 @@ test("attr(String)", function() {
 
        ok( jQuery("<div/>").attr("doesntexist") === undefined, "Make sure undefined is returned when no attribute is found." );
        ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." );
+
+       equals( jQuery(document).attr("nodeName"), "#document", "attr works correctly on document nodes (bug #7451)." );
 });
 
 if ( !isLocal ) {
@@ -409,7 +411,19 @@ test("val(String/Number)", function() {
 
 test("val(Function)", function() {
        testVal(functionReturningObj);
-})
+});
+
+test( "val(Array of Numbers) (Bug #7123)", function() {
+       expect(4);
+       jQuery('#form').append('<input type="checkbox" name="arrayTest" value="1" /><input type="checkbox" name="arrayTest" value="2" /><input type="checkbox" name="arrayTest" value="3" checked="checked" /><input type="checkbox" name="arrayTest" value="4" />');
+       var elements = jQuery('input[name=arrayTest]').val([ 1, 2 ]);
+       ok( elements[0].checked, "First element was checked" );
+       ok( elements[1].checked, "Second element was checked" );
+       ok( !elements[2].checked, "Third element was unchecked" );
+       ok( !elements[3].checked, "Fourth element remained unchecked" );
+       
+       elements.remove();
+});
 
 test("val(Function) with incoming value", function() {
        expect(10);
@@ -500,7 +514,7 @@ test("addClass(Function)", function() {
 });
 
 test("addClass(Function) with incoming value", function() {
-       expect(41);
+       expect(45);
 
        var div = jQuery("div"), old = div.map(function(){
                return jQuery(this).attr("class");
@@ -573,7 +587,7 @@ test("removeClass(Function) - simple", function() {
 });
 
 test("removeClass(Function) with incoming value", function() {
-       expect(41);
+       expect(45);
 
        var $divs = jQuery('div').addClass("test"), old = $divs.map(function(){
                return jQuery(this).attr("class");