]> source.dussan.org Git - jquery.git/commitdiff
Core: move jQuery.fn.nodeName to jQuery.nodeName, add tests
authorMichał Gołębiowski <m.goleb@gmail.com>
Mon, 6 Mar 2017 22:51:26 +0000 (23:51 +0100)
committerTimmy Willison <4timmywil@gmail.com>
Mon, 6 Mar 2017 23:40:51 +0000 (18:40 -0500)
Ref ac9e3016
Close gh-3560

src/deprecated.js
test/unit/deprecated.js

index a18089c41104f59773a56837843dc7294d587b50..195ce7ad92c155337d92ca4e8481a12d98c3363b 100644 (file)
@@ -30,11 +30,11 @@ jQuery.fn.extend( {
                } else {
                        jQuery.ready( true );
                }
-},
-       nodeName: nodeName
+       }
 } );
 
 jQuery.isArray = Array.isArray;
 jQuery.parseJSON = JSON.parse;
+jQuery.nodeName = nodeName;
 
 } );
index b56af0ffe4c4895b65812550e596d510c50ec252..5c05d9b0008ad98167e3913973c320647ac9f905 100644 (file)
@@ -116,3 +116,51 @@ QUnit.test( "jQuery.isArray", function( assert ) {
 
        assert.strictEqual( jQuery.isArray, Array.isArray, "Array.isArray equals jQuery.isArray" );
 } );
+
+QUnit.test( "jQuery.nodeName", function( assert ) {
+       assert.expect( 8 );
+
+       assert.strictEqual( typeof jQuery.nodeName, "function", "jQuery.nodeName is a function" );
+
+       assert.strictEqual(
+               jQuery.nodeName( document.createElement( "div" ), "div" ),
+               true,
+               "Basic usage (true)"
+       );
+
+       assert.strictEqual(
+               jQuery.nodeName( document.createElement( "div" ), "span" ),
+               false,
+               "Basic usage (false)"
+       );
+
+       assert.strictEqual(
+               jQuery.nodeName( document.createElement( "div" ), "DIV" ),
+               true,
+               "Ignores case in the name parameter"
+       );
+
+       assert.strictEqual(
+               jQuery.nodeName( document.createElement( "section" ), "section" ),
+               true,
+               "Works on HTML5 tags (true)"
+       );
+
+       assert.strictEqual(
+               jQuery.nodeName( document.createElement( "section" ), "article" ),
+               false,
+               "Works on HTML5 tags (false)"
+       );
+
+       assert.strictEqual(
+               jQuery.nodeName( document.createElement( "custom-element" ), "custom-element" ),
+               true,
+               "Works on custom elements (true)"
+       );
+
+       assert.strictEqual(
+               jQuery.nodeName( document.createElement( "custom-element" ), "my-element" ),
+               false,
+               "Works on custom elements (true)"
+       );
+} );