From 5ac6ca3fa52a4a27d6952c71a77420e3e4a5d88a Mon Sep 17 00:00:00 2001 From: timmywil Date: Sun, 13 Mar 2011 22:24:45 -0400 Subject: [PATCH] Restored 6 tests that I had commented to come back to later to split up between prop and attr. All tests still pass in all browsers. - I should make it clear that I have not removed any tests, but only moved some attr tests to prop where I thought it was appropriate. --- test/unit/attributes.js | 45 ++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/test/unit/attributes.js b/test/unit/attributes.js index 8b483dccb..89762e76c 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -28,7 +28,8 @@ if ( !jQuery.support.getSetAttribute ) { }); } -test("prop", function() { +test("prop(String)", function() { + expect(19); equals( jQuery('#text1').prop('value'), "Test", 'Check for value attribute' ); equals( jQuery('#text1').prop('value', "Test2").prop('defaultValue'), "Test", 'Check for defaultValue attribute' ); equals( jQuery('#select2').prop('selectedIndex'), 3, 'Check for selectedIndex attribute' ); @@ -57,6 +58,14 @@ test("prop", function() { jQuery.each( [document, attributeNode, commentNode, textNode, obj, "#firstp"], function( i, ele ) { strictEqual( jQuery(ele).prop("nonexisting"), undefined, "prop works correctly for non existing attributes (bug #7500)." ); }); + + var obj = {}; + jQuery.each( [document, obj], function( i, ele ) { + var $ele = jQuery( ele ); + $ele.prop( "nonexisting", "foo" ); + equal( $ele.prop("nonexisting"), "foo", "prop(name, value) works correctly for non existing attributes (bug #7500)." ); + }); + jQuery( document ).removeProp("nonexisting"); }); test("attr(String)", function() { @@ -136,7 +145,7 @@ test("attr(Hash)", function() { }); test("attr(String, Object)", function() { - expect(24); + expect(28); var div = jQuery("div").attr("foo", "bar"), fail = false; @@ -169,25 +178,19 @@ test("attr(String, Object)", function() { equals( document.getElementById('name').maxLength, 5, 'Set maxlength attribute' ); jQuery("#name").attr('maxLength', '10'); equals( document.getElementById('name').maxLength, 10, 'Set maxlength attribute' ); - - // var attributeNode = document.createAttribute("irrelevant"), - // commentNode = document.createComment("some comment"), - // textNode = document.createTextNode("some text"), - // obj = {}; - // jQuery.each( [document, obj, "#firstp"], function( i, ele ) { - // var $ele = jQuery( ele ); - // $ele.attr( "nonexisting", "foo" ); - // equal( $ele.attr("nonexisting"), "foo", "attr(name, value) works correctly for non existing attributes (bug #7500)." ); - // }); - // jQuery.each( [commentNode, textNode, attributeNode], function( i, ele ) { - // var $ele = jQuery( ele ); - // $ele.attr( "nonexisting", "foo" ); - // strictEqual( $ele.attr("nonexisting"), undefined, "attr(name, value) works correctly on comment and text nodes (bug #7500)." ); - // }); - // //cleanup - // jQuery.each( [document, "#firstp"], function( i, ele ) { - // jQuery( ele ).removeAttr("nonexisting"); - // }); + var $p = jQuery('#firstp').attr('nonexisting', 'foo'); + equals( $p.attr('nonexisting'), 'foo', "attr(name, value) works correctly for non existing attributes (bug #7500)."); + $p.removeAttr('nonexisting'); + + var attributeNode = document.createAttribute("irrelevant"), + commentNode = document.createComment("some comment"), + textNode = document.createTextNode("some text"); + + jQuery.each( [commentNode, textNode, attributeNode], function( i, ele ) { + var $ele = jQuery( ele ); + $ele.attr( "nonexisting", "foo" ); + strictEqual( $ele.attr("nonexisting"), undefined, "attr(name, value) works correctly on comment and text nodes (bug #7500)." ); + }); var table = jQuery('#table').append("cellcellcellcellcell"), td = table.find('td:first'); -- 2.39.5