]> source.dussan.org Git - jquery.git/commitdiff
Attributes: fix failing test for new return value
authorTimmy Willison <timmywillisn@gmail.com>
Mon, 16 Mar 2015 15:52:05 +0000 (11:52 -0400)
committerTimmy Willison <timmywillisn@gmail.com>
Mon, 16 Mar 2015 15:52:05 +0000 (11:52 -0400)
src/attributes/attr.js
test/unit/attributes.js

index 3bb05a5a339c49832dde2a81b2880a6d7ac90e56..201a2d2a67f9d42e258a58c42db88a61d6bf901a 100644 (file)
@@ -28,7 +28,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
index c4bd17c1702fc25effc9754b245805f771e09fd2..1163ff4e19099b9e1d98c3cb69a08521d1b066e2 100644 (file)
@@ -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;
        });