Skip to content

Commit

Permalink
Add test for bug #3116
Browse files Browse the repository at this point in the history
  • Loading branch information
timmywil committed Apr 3, 2011
1 parent 47c80c2 commit 3892df2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/attributes.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ jQuery.extend({


// Check form objects in IE (multiple bugs related) // Check form objects in IE (multiple bugs related)
if ( isFormObjects ) { if ( isFormObjects ) {
// Returns undefined for empty string, which is the blank nodeValue in IE // Return undefined for empty string, which is the blank nodeValue in IE
ret = elem.getAttributeNode( name ).nodeValue || undefined; ret = elem.getAttributeNode( name ).nodeValue || undefined;
} else { } else {
ret = elem.getAttribute( name ); ret = elem.getAttribute( name );
Expand Down
16 changes: 12 additions & 4 deletions test/unit/attributes.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ test("attr(Hash)", function() {
}); });


test("attr(String, Object)", function() { test("attr(String, Object)", function() {
expect(28); expect(29);


var div = jQuery("div").attr("foo", "bar"), var div = jQuery("div").attr("foo", "bar"),
fail = false; fail = false;
Expand Down Expand Up @@ -220,9 +220,9 @@ test("attr(String, Object)", function() {
jQuery("#name").attr('someAttr', '0'); jQuery("#name").attr('someAttr', '0');
equals( jQuery("#name").attr('someAttr'), '0', 'Set attribute to a string of "0"' ); equals( jQuery("#name").attr('someAttr'), '0', 'Set attribute to a string of "0"' );
jQuery("#name").attr('someAttr', 0); jQuery("#name").attr('someAttr', 0);
equals( jQuery("#name").attr('someAttr'), 0, 'Set attribute to the number 0' ); equals( jQuery("#name").attr('someAttr'), '0', 'Set attribute to the number 0' );
jQuery("#name").attr('someAttr', 1); jQuery("#name").attr('someAttr', 1);
equals( jQuery("#name").attr('someAttr'), 1, 'Set attribute to the number 1' ); equals( jQuery("#name").attr('someAttr'), '1', 'Set attribute to the number 1' );


// using contents will get comments regular, text, and comment nodes // using contents will get comments regular, text, and comment nodes
var j = jQuery("#nonnodes").contents(); var j = jQuery("#nonnodes").contents();
Expand All @@ -232,7 +232,8 @@ test("attr(String, Object)", function() {
j.removeAttr("name"); j.removeAttr("name");


QUnit.reset(); QUnit.reset();


// Type
var type = jQuery("#check2").attr('type'); var type = jQuery("#check2").attr('type');
var thrown = false; var thrown = false;
try { try {
Expand Down Expand Up @@ -272,6 +273,13 @@ test("attr(String, Object)", function() {
} }
ok( thrown, "Exception thrown when trying to change type property" ); ok( thrown, "Exception thrown when trying to change type property" );
equals( "button", button.attr('type'), "Verify that you can't change the type of a button element" ); equals( "button", button.attr('type'), "Verify that you can't change the type of a button element" );

// Setting attributes on svg elements (bug #3116)
var $svg = jQuery('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="3000" height="3000">'
+ '<circle cx="200" cy="200" r="150" />'
+ '</svg>').appendTo('body');
equals( $svg.attr('cx', 100).attr('cx'), "100", "Set attribute on svg element" );
$svg.remove();
}); });


test("attr(jquery_method)", function(){ test("attr(jquery_method)", function(){
Expand Down

0 comments on commit 3892df2

Please sign in to comment.