mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Attributes: fix failing test for new return value
This commit is contained in:
parent
afca031826
commit
17bd6e9cf9
@ -31,7 +31,7 @@ jQuery.extend({
|
||||
|
||||
// don't get/set attributes on text, comment and attribute nodes
|
||||
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Fallback to prop when attributes are not supported
|
||||
|
@ -377,8 +377,17 @@ test( "attr(String, Object)", function() {
|
||||
jQuery.each( [ window, document, obj, "#firstp" ], function( i, elem ) {
|
||||
var oldVal = elem.nonexisting,
|
||||
$elem = jQuery( elem );
|
||||
strictEqual( $elem.attr("nonexisting"), null, "attr works correctly for non existing attributes (bug #7500)." );
|
||||
equal( $elem.attr( "nonexisting", "foo" ).attr("nonexisting"), "foo", "attr falls back to prop on unsupported arguments" );
|
||||
// Falls back to prop, which returns undefined
|
||||
strictEqual(
|
||||
$elem.attr( "nonexisting" ),
|
||||
typeof $elem[0].getAttribute === "undefined" ? undefined : null,
|
||||
"attr works correctly for non existing attributes (bug #7500)."
|
||||
);
|
||||
equal(
|
||||
$elem.attr( "nonexisting", "foo" ).attr( "nonexisting" ),
|
||||
"foo",
|
||||
"attr falls back to prop on unsupported arguments"
|
||||
);
|
||||
elem.nonexisting = oldVal;
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user