From be041e4da46153465ab4cdc65a4d90245a383a4c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski?= Date: Mon, 6 Mar 2017 23:51:26 +0100 Subject: [PATCH] Core: move jQuery.fn.nodeName to jQuery.nodeName, add tests Ref ac9e3016 Close gh-3560 --- src/deprecated.js | 4 ++-- test/unit/deprecated.js | 48 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) 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)" + ); +} ); -- 2.39.5