diff options
author | timmywil <tim.willison@thisismedium.com> | 2011-03-13 22:24:45 -0400 |
---|---|---|
committer | timmywil <tim.willison@thisismedium.com> | 2011-04-03 19:13:39 -0400 |
commit | 5ac6ca3fa52a4a27d6952c71a77420e3e4a5d88a (patch) | |
tree | 9aa9738daf8d9da251b788c0397808e42777e0e5 /test/unit/attributes.js | |
parent | dbe3b7a9d052b7bf0c73ead1ecd43a40152416a0 (diff) | |
download | jquery-5ac6ca3fa52a4a27d6952c71a77420e3e4a5d88a.tar.gz jquery-5ac6ca3fa52a4a27d6952c71a77420e3e4a5d88a.zip |
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.
Diffstat (limited to 'test/unit/attributes.js')
-rw-r--r-- | test/unit/attributes.js | 45 |
1 files 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("<tr><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr>"), td = table.find('td:first'); |