Skip to content
Permalink
Browse files

Core: Warn and fill jQuery.isWindow

Fixes #263
Closes #290
  • Loading branch information...
dmethvin committed Feb 18, 2018
1 parent f1bba5c commit bf48bce49625e0c558c2f07dd514f2dfa5665334
Showing with 23 additions and 0 deletions.
  1. +9 −0 src/core.js
  2. +9 −0 test/core.js
  3. +5 −0 warnings.md
@@ -89,6 +89,15 @@ jQuery.isNumeric = function( val ) {
return oldValue;
};

if ( jQueryVersionSince( "3.3.0" ) ) {
migrateWarnFunc( jQuery, "isWindow",
function( obj ) {
return obj != null && obj === obj.window;
},
"jQuery.isWindow() is deprecated"
);
}

migrateWarnFunc( jQuery, "holdReady", jQuery.holdReady,
"jQuery.holdReady is deprecated" );

@@ -250,6 +250,15 @@ QUnit.test( "jQuery.isNumeric", function( assert ) {
} );
} );

QUnit[ jQueryVersionSince( "3.3.0" ) ? "test" : "skip" ]( "jQuery.isWindow", function( assert ) {
assert.expect( 3 );

expectWarning( assert, "isWindow", 1, function() {
assert.equal( jQuery.isWindow( [] ), false, "array" );
assert.equal( jQuery.isWindow( window ), true, "window" );
} );
} );

QUnit.test( "jQuery.unique", function( assert ) {
assert.expect( 2 );

@@ -206,6 +206,11 @@ See jQuery-ui [commit](https://github.com/jquery/jquery-ui/commit/c0093b599fcd58

**Solution:** Rewrite the page so that it does not require all jQuery ready handlers to be delayed. This might be accomplished, for example, by late-loading only the code that requires the delay when it is safe to run. Due to the complexity of this method, jQuery Migrate does not attempt to fill the functionality. If the underlying version of jQuery used with jQuery Migrate no longer contains `jQuery.holdReady()` the code will fail shortly after this warning appears.

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

**Cause:** This method returns `true` if its argument is thought to be a `window` element. It was created for internal use and is not a reliable way of detecting `window` for public needs.

**Solution:** Remove any use of `jQuery.isWindow()` from code. If it is truly needed it can be replaced with a check for `obj != null && obj === obj.window` which was the test used inside this method.

### JQMIGRATE: jQuery.fn.click() event shorthand is deprecated

0 comments on commit bf48bce

Please sign in to comment.
You can’t perform that action at this time.