Skip to content

Commit

Permalink
Core: Warn and fill jQuery.nodeName()
Browse files Browse the repository at this point in the history
Fixes #246
Closes #301
  • Loading branch information
dmethvin committed Apr 12, 2018
1 parent 42f1d9e commit f1bba5c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/core.js
Expand Up @@ -100,3 +100,9 @@ migrateWarnProp( jQuery.expr, "filters", jQuery.expr.pseudos,
"jQuery.expr.filters is deprecated; use jQuery.expr.pseudos" );
migrateWarnProp( jQuery.expr, ":", jQuery.expr.pseudos,
"jQuery.expr[':'] is deprecated; use jQuery.expr.pseudos" );

// Prior to jQuery 3.2 there were internal refs so we don't warn there
if ( jQueryVersionSince( "3.2.0" ) ) {
migrateWarnFunc( jQuery, "nodeName", jQuery.nodeName,
"jQuery.nodeName is deprecated" );
}
10 changes: 10 additions & 0 deletions test/core.js
Expand Up @@ -301,6 +301,16 @@ QUnit.test( "jQuery.holdReady (warn only)", function( assert ) {
} );
} );

QUnit[ jQueryVersionSince( "3.2.0" ) ? "test" : "skip" ]( "jQuery.nodeName", function( assert ) {
assert.expect( 2 );

expectWarning( assert, "jQuery.nodeName", function() {
var div = document.createElement( "div" );

assert.equal( jQuery.nodeName( div, "div" ), true, "it's a div" );
})
});

TestManager.runIframeTest( "old pre-3.0 jQuery", "core-jquery2.html",
function( assert, jQuery, window, document, log ) {
assert.expect( 1 );
Expand Down
6 changes: 6 additions & 0 deletions warnings.md
Expand Up @@ -218,3 +218,9 @@ See jQuery-ui [commit](https://github.com/jquery/jquery-ui/commit/c0093b599fcd58
**Cause:** The `.hover()` method is a shorthand for the use of the `mouseover`/`mouseout` events. It is often a poor user interface choice because it does not allow for any small amounts of delay between when the mouse enters or exits an area and when the event fires. This can make it quite difficult to use with UI widgets such as drop-down menus. For more information on the problems of hovering, see the [hoverIntent plugin](http://cherne.net/brian/resources/jquery.hoverIntent.html).

**Solution:** Review uses of `.hover()` to determine if they are appropriate, and consider use of plugins such as `hoverIntent` as an alternative. The direct replacement for `.hover(fn1, fn2)`, is `.on("mouseenter", fn1).on("mouseleave", fn2)`.

### JQMIGRATE: jQuery.nodeName() is deprecated

**Cause:** This public but never-documented method has been deprecated as of jQuery 3.2.0.

**Solution:** Replace calls such as `jQuery.nodeName( elem, "div" )` with a test such as `elem.nodeName.toLowerCase() === "div"`.

0 comments on commit f1bba5c

Please sign in to comment.