From: Michał Gołębiowski Date: Mon, 6 Mar 2017 22:51:26 +0000 (+0100) Subject: Core: move jQuery.fn.nodeName to jQuery.nodeName, add tests X-Git-Tag: 3.2.0~10 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=be041e4da46153465ab4cdc65a4d90245a383a4c;p=jquery.git Core: move jQuery.fn.nodeName to jQuery.nodeName, add tests Ref ac9e3016 Close gh-3560 --- diff --git a/src/deprecated.js b/src/deprecated.js index a18089c41..195ce7ad9 100644 --- a/src/deprecated.js +++ b/src/deprecated.js @@ -30,11 +30,11 @@ jQuery.fn.extend( { } else { jQuery.ready( true ); } -}, - nodeName: nodeName + } } ); jQuery.isArray = Array.isArray; jQuery.parseJSON = JSON.parse; +jQuery.nodeName = nodeName; } ); diff --git a/test/unit/deprecated.js b/test/unit/deprecated.js index b56af0ffe..5c05d9b00 100644 --- a/test/unit/deprecated.js +++ b/test/unit/deprecated.js @@ -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)" + ); +} );