Skip to content

Commit

Permalink
Merge branch 'attrFollowupFix' of https://github.com/jitter/jquery in…
Browse files Browse the repository at this point in the history
…to jitter-attrFollowupFix
  • Loading branch information
jeresig committed Dec 9, 2010
2 parents a13089d + cc9dbd0 commit b2ea79c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ jQuery.extend({
},

attr: function( elem, name, value, pass ) {
// don't set attributes on text and comment nodes
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
// don't get/set attributes on text, comment and attribute nodes
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || elem.nodeType === 2 ) {
return undefined;
}

Expand Down
8 changes: 4 additions & 4 deletions test/unit/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ test("attr(String, Object)", function() {
commentNode = document.createComment("some comment"),
textNode = document.createTextNode("some text"),
obj = {};
jQuery.each( [document, attributeNode, obj, "#firstp"], function( i, ele ) {
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], function( i, ele ) {
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)." );
Expand Down Expand Up @@ -366,12 +366,12 @@ test("removeAttr(String)", function() {
//removeAttr only really removes on DOM element nodes handle all other seperatyl
strictEqual( jQuery( "#firstp" ).attr( "nonexisting", "foo" ).removeAttr( "nonexisting" )[0].nonexisting, undefined, "removeAttr works correctly on DOM element nodes" );

jQuery.each( [document, attributeNode, obj], function( i, ele ) {
jQuery.each( [document, obj], function( i, ele ) {
var $ele = jQuery( ele );
$ele.attr( "nonexisting", "foo" ).removeAttr( "nonexisting" );
strictEqual( ele.nonexisting, "", "removeAttr works correctly on non DOM element nodes (bug #7500)." );
});
jQuery.each( [commentNode, textNode], function( i, ele ) {
jQuery.each( [commentNode, textNode, attributeNode], function( i, ele ) {
$ele = jQuery( ele );
$ele.attr( "nonexisting", "foo" ).removeAttr( "nonexisting" );
strictEqual( ele.nonexisting, undefined, "removeAttr works correctly on non DOM element nodes (bug #7500)." );
Expand Down

0 comments on commit b2ea79c

Please sign in to comment.