Skip to content

Commit

Permalink
Core: Warn and fill jQuery.isWindow
Browse files Browse the repository at this point in the history
Fixes jquery#263
Closes jquery#290
  • Loading branch information
dmethvin committed Apr 12, 2018
1 parent f1bba5c commit bf48bce
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" );

Expand Down
9 changes: 9 additions & 0 deletions test/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
5 changes: 5 additions & 0 deletions warnings.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit bf48bce

Please sign in to comment.