Skip to content

Commit 17bd6e9

Browse files
committed
Attributes: fix failing test for new return value
1 parent afca031 commit 17bd6e9

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/attributes/attr.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jQuery.extend({
3131

3232
// don't get/set attributes on text, comment and attribute nodes
3333
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
34-
return;
34+
return null;
3535
}
3636

3737
// Fallback to prop when attributes are not supported

test/unit/attributes.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,17 @@ test( "attr(String, Object)", function() {
377377
jQuery.each( [ window, document, obj, "#firstp" ], function( i, elem ) {
378378
var oldVal = elem.nonexisting,
379379
$elem = jQuery( elem );
380-
strictEqual( $elem.attr("nonexisting"), null, "attr works correctly for non existing attributes (bug #7500)." );
381-
equal( $elem.attr( "nonexisting", "foo" ).attr("nonexisting"), "foo", "attr falls back to prop on unsupported arguments" );
380+
// Falls back to prop, which returns undefined
381+
strictEqual(
382+
$elem.attr( "nonexisting" ),
383+
typeof $elem[0].getAttribute === "undefined" ? undefined : null,
384+
"attr works correctly for non existing attributes (bug #7500)."
385+
);
386+
equal(
387+
$elem.attr( "nonexisting", "foo" ).attr( "nonexisting" ),
388+
"foo",
389+
"attr falls back to prop on unsupported arguments"
390+
);
382391
elem.nonexisting = oldVal;
383392
});
384393

0 commit comments

Comments
 (0)