Remove conditional that prevents attr from working on non-Element nodes. Fixes #7451.

This commit is contained in:
Colin Snover 2010-11-09 15:52:20 -05:00 committed by John Resig
parent d1a88b2e58
commit a64dc04050
2 changed files with 81 additions and 82 deletions

View file

@ -289,8 +289,6 @@ jQuery.extend({
// Try to normalize/fix the name
name = notxml && jQuery.props[ name ] || name;
// Only do all the following if this is a node (faster for style)
if ( elem.nodeType === 1 ) {
// These attributes require special treatment
var special = rspecialurl.test( name );
@ -374,7 +372,6 @@ jQuery.extend({
// Non-existent attributes return null, we normalize to undefined
return attr === null ? undefined : attr;
}
}
});
})( jQuery );

View 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 ) {