All: Migrate away from deprecated/removed Core APIs

Summary of the changes:

* Build: Add jQuery 3.2.0-3.4.1 to versions UI can be tested against
* Build: Load jQuery & Migrate via HTTPS
* Build: Add package-lock.json to .gitignore
* Build: Update jQuery Migrate from 3.0.0 to 3.1.0
* Build: Allow to run tests against jQuery 3.x-git
* Build: Fix formatting according to JSCS rules
* Build: Disable JSCS for the inlined jQuery Color
* All: Switch from $.isArray to Array.isArray (jQuery.isArray will be
  removed in jQuery 4.0)
* All: Switch from `$.isFunction( x )` to `typeof x === "function"`
  (jQuery.isFunction will be removed in jQuery 4.0)
* All: Inline jQuery.isWindow as it'll be removed in jQuery 4.0
* Effects: Fix a timing issue in a variable declaration. Previously,
  a jQuery object was created, chained & assigned to a variable that
  was then accessed in a callback used inside of this chained
  definition. Due to a timing difference in when the callback fired for
  the first time in latest jQuery master, it was being called before
  the variable was defined.
* Tests: Make dialog & draggable unit tests less strict (newest jQuery
  returns fractional results in some cases, making comparisons fail when
  there's a tiny difference)
* All: Migrate from $.trim to bare String.prototype.trim (jQuery.trim
  will be deprecated in jQuery 3.5)

Closes gh-1901
This commit is contained in:
Michał Gołębiowski-Owczarek 2019-12-08 22:23:08 +01:00
parent 74f8a0ac95
commit 98b539171b
51 changed files with 62976 additions and 178 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ dist
bower_components
node_modules
.sizecache.json
package-lock.json

View File

@ -3,6 +3,7 @@ module.exports = function( grunt ) {
"use strict";
var
// files
coreFiles = [
"core.js",
@ -16,11 +17,11 @@ var
"effect.js"
],
uiFiles = coreFiles.map(function( file ) {
uiFiles = coreFiles.map( function( file ) {
return "ui/" + file;
}).concat( expandFiles( "ui/**/*.js" ).filter(function( file ) {
} ).concat( expandFiles( "ui/**/*.js" ).filter( function( file ) {
return coreFiles.indexOf( file.substring( 3 ) ) === -1;
}) ),
} ) ),
allI18nFiles = expandFiles( "ui/i18n/*.js" ),
@ -45,9 +46,9 @@ var
"tabs",
"tooltip",
"theme"
].map(function( component ) {
].map( function( component ) {
return "themes/base/" + component + ".css";
}),
} ),
// minified files
minify = {
@ -92,12 +93,12 @@ function mapMinFile( file ) {
}
function expandFiles( files ) {
return grunt.util._.pluck( grunt.file.expandMapping( files ), "src" ).map(function( values ) {
return grunt.util._.pluck( grunt.file.expandMapping( files ), "src" ).map( function( values ) {
return values[ 0 ];
});
} );
}
uiFiles.concat( allI18nFiles ).forEach(function( file ) {
uiFiles.concat( allI18nFiles ).forEach( function( file ) {
minify[ file ] = {
options: {
banner: createBanner()
@ -105,15 +106,17 @@ uiFiles.concat( allI18nFiles ).forEach(function( file ) {
files: {}
};
minify[ file ].files[ mapMinFile( file ) ] = file;
});
} );
uiFiles.forEach( function( file ) {
uiFiles.forEach(function( file ) {
// TODO this doesn't do anything until https://github.com/rwldrn/grunt-compare-size/issues/13
compareFiles[ file ] = [ file, mapMinFile( file ) ];
});
} );
// grunt plugins
require( "load-grunt-tasks" )( grunt );
// local testswarm and build tasks
grunt.loadTasks( "build/tasks" );
@ -122,17 +125,18 @@ function stripDirectory( file ) {
}
function createBanner( files ) {
// strip folders
var fileNames = files && files.map( stripDirectory );
return "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
"<%= grunt.template.today('isoDate') %>\n" +
"<%= pkg.homepage ? '* ' + pkg.homepage + '\\n' : '' %>" +
(files ? "* Includes: " + fileNames.join(", ") + "\n" : "") +
( files ? "* Includes: " + fileNames.join( ", " ) + "\n" : "" ) +
"* Copyright <%= pkg.author.name %>;" +
" Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */\n";
}
grunt.initConfig({
grunt.initConfig( {
pkg: grunt.file.readJSON( "package.json" ),
files: {
dist: "<%= pkg.name %>-<%= pkg.version %>"
@ -166,7 +170,7 @@ grunt.initConfig({
include: expandFiles( [ "ui/**/*.js", "!ui/core.js", "!ui/i18n/*" ] ),
out: "dist/jquery-ui.js",
wrap: {
start: createBanner( uiFiles ),
start: createBanner( uiFiles )
}
}
}
@ -215,9 +219,9 @@ grunt.initConfig({
}
},
qunit: {
files: expandFiles( "tests/unit/" + component + "/*.html" ).filter(function( file ) {
files: expandFiles( "tests/unit/" + component + "/*.html" ).filter( function( file ) {
return !( /(all|index|test)\.html$/ ).test( file );
}),
} ),
options: {
inject: false,
page: {
@ -397,6 +401,24 @@ grunt.initConfig({
"jquery-3.1.1/jquery.js": "jquery-3.1.1/dist/jquery.js",
"jquery-3.1.1/LICENSE.txt": "jquery-3.1.1/LICENSE.txt",
"jquery-3.2.0/jquery.js": "jquery-3.2.0/dist/jquery.js",
"jquery-3.2.0/LICENSE.txt": "jquery-3.2.0/LICENSE.txt",
"jquery-3.2.1/jquery.js": "jquery-3.2.1/dist/jquery.js",
"jquery-3.2.1/LICENSE.txt": "jquery-3.2.1/LICENSE.txt",
"jquery-3.3.0/jquery.js": "jquery-3.3.0/dist/jquery.js",
"jquery-3.3.0/LICENSE.txt": "jquery-3.3.0/LICENSE.txt",
"jquery-3.3.1/jquery.js": "jquery-3.3.1/dist/jquery.js",
"jquery-3.3.1/LICENSE.txt": "jquery-3.3.1/LICENSE.txt",
"jquery-3.4.0/jquery.js": "jquery-3.4.0/dist/jquery.js",
"jquery-3.4.0/LICENSE.txt": "jquery-3.4.0/LICENSE.txt",
"jquery-3.4.1/jquery.js": "jquery-3.4.1/dist/jquery.js",
"jquery-3.4.1/LICENSE.txt": "jquery-3.4.1/LICENSE.txt",
"jquery-migrate-1.4.1/jquery-migrate.js": "jquery-migrate-1.4.1/dist/jquery-migrate.js",
"jquery-migrate-1.4.1/LICENSE.txt": "jquery-migrate-1.4.1/LICENSE.txt",
@ -432,13 +454,13 @@ grunt.initConfig({
"Bohdan Ganicky <bohdan.ganicky@gmail.com>"
]
}
});
} );
grunt.registerTask( "update-authors", function() {
var getAuthors = require( "grunt-git-authors" ).getAuthors,
done = this.async();
getAuthors({
getAuthors( {
priorAuthors: grunt.config( "authors.prior" )
}, function( error, authors ) {
if ( error ) {
@ -446,7 +468,7 @@ grunt.registerTask( "update-authors", function() {
return done( false );
}
authors = authors.map(function( author ) {
authors = authors.map( function( author ) {
if ( author.match( /^Jacek Jędrzejewski </ ) ) {
return "Jacek Jędrzejewski (http://jacek.jedrzejewski.name)";
} else if ( author.match( /^Pawel Maruszczyk </ ) ) {
@ -454,21 +476,21 @@ grunt.registerTask( "update-authors", function() {
} else {
return author;
}
});
} );
grunt.file.write( "AUTHORS.txt",
"Authors ordered by first contribution\n" +
"A list of current team members is available at http://jqueryui.com/about\n\n" +
authors.join( "\n" ) + "\n" );
done();
});
});
} );
} );
grunt.registerTask( "default", [ "lint", "requirejs", "test" ]);
grunt.registerTask( "jenkins", [ "default", "concat" ]);
grunt.registerTask( "lint", [ "asciilint", "jshint", "jscs", "csslint", "htmllint" ]);
grunt.registerTask( "test", [ "qunit" ]);
grunt.registerTask( "sizer", [ "requirejs:js", "uglify:main", "compare_size:all" ]);
grunt.registerTask( "sizer_all", [ "requirejs:js", "uglify", "compare_size" ]);
grunt.registerTask( "default", [ "lint", "requirejs", "test" ] );
grunt.registerTask( "jenkins", [ "default", "concat" ] );
grunt.registerTask( "lint", [ "asciilint", "jshint", "jscs", "csslint", "htmllint" ] );
grunt.registerTask( "test", [ "qunit" ] );
grunt.registerTask( "sizer", [ "requirejs:js", "uglify:main", "compare_size:all" ] );
grunt.registerTask( "sizer_all", [ "requirejs:js", "uglify", "compare_size" ] );
};

View File

@ -60,6 +60,12 @@
"jquery-3.0.0": "jquery#3.0.0",
"jquery-3.1.0": "jquery#3.1.0",
"jquery-3.1.1": "jquery#3.1.1",
"jquery-3.2.0": "jquery#3.2.0",
"jquery-3.2.1": "jquery#3.2.1",
"jquery-3.3.0": "jquery#3.3.0",
"jquery-3.3.1": "jquery#3.3.1",
"jquery-3.4.0": "jquery#3.4.0",
"jquery-3.4.1": "jquery#3.4.1",
"jquery-migrate-1.4.1": "https://registry.npmjs.org/jquery-migrate/-/jquery-migrate-1.4.1.tgz",
"jquery-migrate-3.0.0": "https://registry.npmjs.org/jquery-migrate/-/jquery-migrate-3.0.0.tgz"
}

View File

@ -4,6 +4,10 @@ module.exports = function( grunt ) {
var versions = {
"git": "git",
"3.x-git": "3.x-git",
"3.4": "3.4.1",
"3.3": "3.3.1",
"3.2": "3.2.1",
"3.1": "3.1.1",
"3.0": "3.0.0",
"2.2": "2.2.4",

View File

@ -25,7 +25,8 @@
var data = $( "geoname", xmlResponse ).map(function() {
return {
value: $( "name", this ).text() + ", " +
( $.trim( $( "countryName", this ).text() ) || "(unknown country)" ),
( String.prototype.trim.call( $( "countryName", this ).text() ) ||
"(unknown country)" ),
id: $( "geonameId", this ).text()
};
}).get();

View File

@ -37,7 +37,9 @@
<script src="../../external/requirejs/require.js"></script>
<script src="../bootstrap.js" data-modules="button controlgroup menu effect effect-blind">
function notify( input ) {
var msg = "Selected " + $.trim( input.data( "tooltip-title" ) || input.text() );
var msg = "Selected " +
String.prototype.trim.call(
input.data( "tooltip-title" ) || input.text() );
$( "<div>" )
.appendTo( document.body )
.text( msg )

36
external/jquery-3.2.0/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,36 @@
Copyright JS Foundation and other contributors, https://js.foundation/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

10244
external/jquery-3.2.0/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

36
external/jquery-3.2.1/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,36 @@
Copyright JS Foundation and other contributors, https://js.foundation/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

10253
external/jquery-3.2.1/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

36
external/jquery-3.3.0/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,36 @@
Copyright JS Foundation and other contributors, https://js.foundation/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

10364
external/jquery-3.3.0/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

36
external/jquery-3.3.1/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,36 @@
Copyright JS Foundation and other contributors, https://js.foundation/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

10364
external/jquery-3.3.1/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

20
external/jquery-3.4.0/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,20 @@
Copyright JS Foundation and other contributors, https://js.foundation/
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

10588
external/jquery-3.4.0/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

20
external/jquery-3.4.1/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,20 @@
Copyright JS Foundation and other contributors, https://js.foundation/
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

10598
external/jquery-3.4.1/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
Copyright OpenJS Foundation and other contributors, https://openjsf.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history

View File

@ -1,37 +1,74 @@
/*!
* jQuery Migrate - v3.0.0 - 2016-06-09
* Copyright jQuery Foundation and other contributors
* jQuery Migrate - v3.1.0 - 2019-06-08
* Copyright OpenJS Foundation and other contributors
*/
(function( jQuery, window ) {
;( function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
define( [ "jquery" ], function ( jQuery ) {
return factory( jQuery, window );
} );
} else if ( typeof module === "object" && module.exports ) {
// Node/CommonJS
// eslint-disable-next-line no-undef
module.exports = factory( require( "jquery" ), window );
} else {
// Browser globals
factory( jQuery, window );
}
} )( function( jQuery, window ) {
"use strict";
jQuery.migrateVersion = "3.0.0";
jQuery.migrateVersion = "3.1.0";
/* exported jQueryVersionSince, compareVersions */
// Returns 0 if v1 == v2, -1 if v1 < v2, 1 if v1 > v2
function compareVersions( v1, v2 ) {
var rVersionParts = /^(\d+)\.(\d+)\.(\d+)/,
v1p = rVersionParts.exec( v1 ) || [ ],
v2p = rVersionParts.exec( v2 ) || [ ];
for ( var i = 1; i <= 3; i++ ) {
if ( +v1p[ i ] > +v2p[ i ] ) {
return 1;
}
if ( +v1p[ i ] < +v2p[ i ] ) {
return -1;
}
}
return 0;
}
function jQueryVersionSince( version ) {
return compareVersions( jQuery.fn.jquery, version ) >= 0;
}
/* exported migrateWarn, migrateWarnFunc, migrateWarnProp */
( function() {
// Support: IE9 only
// IE9 only creates console object when dev tools are first opened
// Also, avoid Function#bind here to simplify PhantomJS usage
var log = window.console && window.console.log &&
function() { window.console.log.apply( window.console, arguments ); },
rbadVersions = /^[12]\./;
if ( !log ) {
// IE9 console is a host object, callable but doesn't have .apply()
if ( !window.console || !window.console.log ) {
return;
}
// Need jQuery 3.0.0+ and no older Migrate loaded
if ( !jQuery || rbadVersions.test( jQuery.fn.jquery ) ) {
log( "JQMIGRATE: jQuery 3.0.0+ REQUIRED" );
if ( !jQuery || !jQueryVersionSince( "3.0.0" ) ) {
window.console.log( "JQMIGRATE: jQuery 3.0.0+ REQUIRED" );
}
if ( jQuery.migrateWarnings ) {
log( "JQMIGRATE: Migrate plugin loaded multiple times" );
window.console.log( "JQMIGRATE: Migrate plugin loaded multiple times" );
}
// Show a message on the console so devs know we're active
log( "JQMIGRATE: Migrate is installed" +
window.console.log( "JQMIGRATE: Migrate is installed" +
( jQuery.migrateMute ? "" : " with logging active" ) +
", version " + jQuery.migrateVersion );
@ -74,11 +111,22 @@ function migrateWarnProp( obj, prop, value, msg ) {
get: function() {
migrateWarn( msg );
return value;
},
set: function( newValue ) {
migrateWarn( msg );
value = newValue;
}
} );
}
if ( document.compatMode === "BackCompat" ) {
function migrateWarnFunc( obj, prop, newFunc, msg ) {
obj[ prop ] = function() {
migrateWarn( msg );
return newFunc.apply( this, arguments );
};
}
if ( window.document.compatMode === "BackCompat" ) {
// JQuery has never supported or tested Quirks Mode
migrateWarn( "jQuery is not compatible with Quirks Mode" );
@ -115,7 +163,7 @@ jQuery.find = function( selector ) {
// The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0
// First see if qS thinks it's a valid selector, if so avoid a false positive
try {
document.querySelector( selector );
window.document.querySelector( selector );
} catch ( err1 ) {
// Didn't *look* valid to qSA, warn and try quoting what we think is the value
@ -126,7 +174,7 @@ jQuery.find = function( selector ) {
// If the regexp *may* have created an invalid selector, don't update it
// Note that there may be false alarms if selector uses jQuery extensions
try {
document.querySelector( selector );
window.document.querySelector( selector );
migrateWarn( "Attribute selector with '#' must be quoted: " + args[ 0 ] );
args[ 0 ] = selector;
} catch ( err2 ) {
@ -148,7 +196,7 @@ for ( findProp in oldFind ) {
// The number of elements contained in the matched element set
jQuery.fn.size = function() {
migrateWarn( "jQuery.fn.size() is deprecated; use the .length property" );
migrateWarn( "jQuery.fn.size() is deprecated and removed; use the .length property" );
return this.length;
};
@ -175,14 +223,32 @@ jQuery.isNumeric = function( val ) {
return oldValue;
};
migrateWarnProp( jQuery, "unique", jQuery.uniqueSort,
"jQuery.unique is deprecated, use jQuery.uniqueSort" );
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" );
migrateWarnFunc( jQuery, "unique", jQuery.uniqueSort,
"jQuery.unique is deprecated; use jQuery.uniqueSort" );
// Now jQuery.expr.pseudos is the standard incantation
migrateWarnProp( jQuery.expr, "filters", jQuery.expr.pseudos,
"jQuery.expr.filters is now jQuery.expr.pseudos" );
"jQuery.expr.filters is deprecated; use jQuery.expr.pseudos" );
migrateWarnProp( jQuery.expr, ":", jQuery.expr.pseudos,
"jQuery.expr[\":\"] is now 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" );
}
var oldAjax = jQuery.ajax;
@ -192,11 +258,11 @@ jQuery.ajax = function( ) {
// Be sure we got a jQXHR (e.g., not sync)
if ( jQXHR.promise ) {
migrateWarnProp( jQXHR, "success", jQXHR.done,
migrateWarnFunc( jQXHR, "success", jQXHR.done,
"jQXHR.success is deprecated and removed" );
migrateWarnProp( jQXHR, "error", jQXHR.fail,
migrateWarnFunc( jQXHR, "error", jQXHR.fail,
"jQXHR.error is deprecated and removed" );
migrateWarnProp( jQXHR, "complete", jQXHR.always,
migrateWarnFunc( jQXHR, "complete", jQXHR.always,
"jQXHR.complete is deprecated and removed" );
}
@ -211,7 +277,7 @@ var oldRemoveAttr = jQuery.fn.removeAttr,
jQuery.fn.removeAttr = function( name ) {
var self = this;
jQuery.each( name.match( rmatchNonSpace ), function( i, attr ) {
jQuery.each( name.match( rmatchNonSpace ), function( _i, attr ) {
if ( jQuery.expr.match.bool.test( attr ) ) {
migrateWarn( "jQuery.fn.removeAttr no longer sets boolean properties: " + attr );
self.prop( attr, false );
@ -302,8 +368,26 @@ var oldData = jQuery.data;
jQuery.data = function( elem, name, value ) {
var curData;
// Name can be an object, and each entry in the object is meant to be set as data
if ( name && typeof name === "object" && arguments.length === 2 ) {
curData = jQuery.hasData( elem ) && oldData.call( this, elem );
var sameKeys = {};
for ( var key in name ) {
if ( key !== jQuery.camelCase( key ) ) {
migrateWarn( "jQuery.data() always sets/gets camelCased names: " + key );
curData[ key ] = name[ key ];
} else {
sameKeys[ key ] = name[ key ];
}
}
oldData.call( this, elem, sameKeys );
return name;
}
// If the name is transformed, look for the un-transformed name in the data object
if ( name && name !== jQuery.camelCase( name ) ) {
if ( name && typeof name === "string" && name !== jQuery.camelCase( name ) ) {
curData = jQuery.hasData( elem ) && oldData.call( this, elem );
if ( curData && name in curData ) {
migrateWarn( "jQuery.data() always sets/gets camelCased names: " + name );
@ -318,30 +402,55 @@ jQuery.data = function( elem, name, value ) {
};
var oldTweenRun = jQuery.Tween.prototype.run;
var linearEasing = function( pct ) {
return pct;
};
jQuery.Tween.prototype.run = function( percent ) {
jQuery.Tween.prototype.run = function( ) {
if ( jQuery.easing[ this.easing ].length > 1 ) {
migrateWarn(
"easing function " +
"\"jQuery.easing." + this.easing.toString() +
"\" should use only first argument"
"'jQuery.easing." + this.easing.toString() + "' should use only one argument"
);
jQuery.easing[ this.easing ] = jQuery.easing[ this.easing ].bind(
jQuery.easing,
percent, this.options.duration * percent, 0, 1, this.options.duration
);
jQuery.easing[ this.easing ] = linearEasing;
}
oldTweenRun.apply( this, arguments );
};
var intervalValue = jQuery.fx.interval || 13,
intervalMsg = "jQuery.fx.interval is deprecated";
// Support: IE9, Android <=4.4
// Avoid false positives on browsers that lack rAF
// Don't warn if document is hidden, jQuery uses setTimeout (#292)
if ( window.requestAnimationFrame ) {
Object.defineProperty( jQuery.fx, "interval", {
configurable: true,
enumerable: true,
get: function() {
if ( !window.document.hidden ) {
migrateWarn( intervalMsg );
}
return intervalValue;
},
set: function( newValue ) {
migrateWarn( intervalMsg );
intervalValue = newValue;
}
} );
}
var oldLoad = jQuery.fn.load,
oldEventAdd = jQuery.event.add,
originalFix = jQuery.event.fix;
jQuery.event.props = [];
jQuery.event.fixHooks = {};
migrateWarnProp( jQuery.event.props, "concat", jQuery.event.props.concat,
"jQuery.event.props.concat() is deprecated and removed" );
jQuery.event.fix = function( originalEvent ) {
var event,
type = originalEvent.type,
@ -360,7 +469,7 @@ jQuery.event.fix = function( originalEvent ) {
migrateWarn( "jQuery.event.fixHooks are deprecated and removed: " + type );
if ( ( props = fixHook.props ) && props.length ) {
while ( props.length ) {
jQuery.event.addProp( props.pop() );
jQuery.event.addProp( props.pop() );
}
}
}
@ -370,6 +479,15 @@ jQuery.event.fix = function( originalEvent ) {
return fixHook && fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
};
jQuery.event.add = function( elem, types ) {
// This misses the multiple-types case but that seems awfully rare
if ( elem === window && types === "load" && window.document.readyState === "complete" ) {
migrateWarn( "jQuery(window).on('load'...) called after load event occurred" );
}
return oldEventAdd.apply( this, arguments );
};
jQuery.each( [ "load", "unload", "error" ], function( _, name ) {
jQuery.fn[ name ] = function() {
@ -400,14 +518,28 @@ jQuery.each( [ "load", "unload", "error" ], function( _, name ) {
} );
jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
"change select submit keydown keypress keyup contextmenu" ).split( " " ),
function( _i, name ) {
// Handle event binding
jQuery.fn[ name ] = function( data, fn ) {
migrateWarn( "jQuery.fn." + name + "() event shorthand is deprecated" );
return arguments.length > 0 ?
this.on( name, null, data, fn ) :
this.trigger( name );
};
} );
// Trigger "ready" event only once, on document ready
jQuery( function() {
jQuery( document ).triggerHandler( "ready" );
jQuery( window.document ).triggerHandler( "ready" );
} );
jQuery.event.special.ready = {
setup: function() {
if ( this === document ) {
if ( this === window.document ) {
migrateWarn( "'ready' event is deprecated" );
}
}
@ -432,6 +564,10 @@ jQuery.fn.extend( {
return arguments.length === 1 ?
this.off( selector, "**" ) :
this.off( types, selector || "**", fn );
},
hover: function( fnOver, fnOut ) {
migrateWarn( "jQuery.fn.hover() is deprecated" );
return this.on( "mouseenter", fnOver ).on( "mouseleave", fnOut || fnOver );
}
} );
@ -448,7 +584,7 @@ jQuery.fn.offset = function() {
return origin;
}
docElem = ( elem.ownerDocument || document ).documentElement;
docElem = ( elem.ownerDocument || window.document ).documentElement;
if ( !jQuery.contains( docElem, elem ) ) {
migrateWarn( "jQuery.fn.offset() requires an element connected to a document" );
return origin;
@ -475,7 +611,7 @@ jQuery.param = function( data, traditional ) {
var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack;
jQuery.fn.andSelf = function() {
migrateWarn( "jQuery.fn.andSelf() replaced by jQuery.fn.addBack()" );
migrateWarn( "jQuery.fn.andSelf() is deprecated and removed, use jQuery.fn.addBack()" );
return oldSelf.apply( this, arguments );
};
@ -535,6 +671,8 @@ jQuery.Deferred = function( func ) {
return deferred;
};
// Preserve handler of uncaught exceptions in promise chains
jQuery.Deferred.exceptionHook = oldDeferred.exceptionHook;
})( jQuery, window );
return jQuery;
} );

View File

@ -104,8 +104,8 @@ function jqueryUrl() {
var version = parseUrl().jquery || DEFAULT_JQUERY_VERSION;
var url;
if ( version === "git" ) {
url = "http://code.jquery.com/jquery-" + version;
if ( version === "git" || version === "3.x-git" ) {
url = "https://code.jquery.com/jquery-" + version;
} else {
url = "../../../external/jquery-" + version + "/jquery";
}
@ -118,9 +118,9 @@ function migrateUrl() {
var url;
if ( jqueryVersion === "git" ) {
url = "http://code.jquery.com/jquery-migrate-git";
url = "https://code.jquery.com/jquery-migrate-git";
} else if ( jqueryVersion[ 0 ] === "3" ) {
url = "../../../external/jquery-migrate-3.0.0/jquery-migrate";
url = "../../../external/jquery-migrate-3.1.0/jquery-migrate";
} else if ( jqueryVersion[ 0 ] === "1" || jqueryVersion[ 0 ] === "2" ) {
url = "../../../external/jquery-migrate-1.4.1/jquery-migrate";
} else if ( jqueryVersion === "custom" ) {

View File

@ -13,8 +13,8 @@ function testWidgetDefaults( widget, defaults ) {
var count = 0;
$.each( defaults, function( key, val ) {
assert.expect( ++count );
if ( $.isFunction( val ) ) {
assert.ok( $.isFunction( pluginDefaults[ key ] ), key );
if ( typeof val === "function" ) {
assert.ok( typeof pluginDefaults[ key ] === "function", key );
return;
}
assert.deepEqual( pluginDefaults[ key ], val, key );

View File

@ -31,6 +31,9 @@ QUnit.config.urlConfig.push( {
"2.2.0", "2.2.1", "2.2.2", "2.2.3", "2.2.4",
"3.0.0",
"3.1.0", "3.1.1",
"3.2.0", "3.2.1",
"3.3.0", "3.3.1",
"3.4.0", "3.4.1",
"git", "custom"
],
tooltip: "Which jQuery Core version to test against"

View File

@ -137,7 +137,7 @@ QUnit.test( "label - default", function( assert ) {
widget = checkbox.checkboxradio( "widget" );
assert.strictEqual( checkbox.checkboxradio( "option", "label" ),
"checkbox label", "When no value passed on create text from dom is used for option" );
assert.strictEqual( $.trim( widget.text() ),
assert.strictEqual( String.prototype.trim.call( widget.text() ),
"checkbox label", "When no value passed on create text from dom is used in dom" );
} );
@ -152,7 +152,7 @@ QUnit.test( "label - explicit value", function( assert ) {
assert.strictEqual( checkbox.checkboxradio( "option", "label" ),
"foo", "When value is passed on create value is used for option" );
assert.strictEqual( $.trim( widget.text() ),
assert.strictEqual( String.prototype.trim.call( widget.text() ),
"foo", "When value is passed on create value is used in dom" );
assert.strictEqual( icon.length, 1,
"Icon is preserved when label is set on init when wrapped in label" );
@ -177,7 +177,7 @@ QUnit.test( "label - explicit null value", function( assert ) {
widget = checkbox.checkboxradio( "widget" );
assert.strictEqual( checkbox.checkboxradio( "option", "label" ),
"checkbox label", "When null is passed on create text from dom is used for option" );
assert.strictEqual( $.trim( widget.text() ),
assert.strictEqual( String.prototype.trim.call( widget.text() ),
"checkbox label", "When null is passed on create text from dom is used in dom" );
} );
@ -193,13 +193,13 @@ QUnit.test( "label", function( assert ) {
checkbox.checkboxradio( "option", "label", "bar" );
assert.strictEqual( checkbox.checkboxradio( "option", "label" ),
"bar", "When value is passed value is used for option" );
assert.strictEqual( $.trim( widget.text() ),
assert.strictEqual( String.prototype.trim.call( widget.text() ),
"bar", "When value is passed value is used in dom" );
checkbox.checkboxradio( "option", "label", null );
assert.strictEqual( checkbox.checkboxradio( "option", "label" ),
"bar", "When null is passed text from dom is used for option" );
assert.strictEqual( $.trim( widget.text() ),
assert.strictEqual( String.prototype.trim.call( widget.text() ),
"bar", "When null is passed text from dom is used in dom" );
} );

View File

@ -152,8 +152,9 @@ QUnit.test( "Labels", function( assert ) {
var found = labels.map( function() {
// Support: Core 1.9 Only
// We use $.trim() because core 1.9.x silently fails when white space is present
return $.trim( $( this ).text() );
// We use String.prototype.trim because core 1.9.x silently fails
// when white space is present
return String.prototype.trim.call( $( this ).text() );
} ).get();
assert.deepEqual( found, expected,

View File

@ -50,7 +50,7 @@ QUnit.test( "buttons - deprecated options", function( assert ) {
buttons = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" );
assert.equal( buttons.length, 1, "correct number of buttons" );
assert.equal( buttons.attr( "id" ), "my-button-id", "correct id" );
assert.equal( $.trim( buttons.text() ), "a button", "correct label" );
assert.equal( String.prototype.trim.call( buttons.text() ), "a button", "correct label" );
assert.hasClasses( buttons, "additional-class" );
assert.deepEqual( buttons.button( "option", "icon" ), "ui-icon-cancel" );
assert.equal( buttons.button( "option", "showLabel" ), false );

View File

@ -166,7 +166,7 @@ QUnit.test( "buttons - advanced", function( assert ) {
buttons = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" );
assert.equal( buttons.length, 1, "correct number of buttons" );
assert.equal( buttons.attr( "id" ), "my-button-id", "correct id" );
assert.equal( $.trim( buttons.text() ), "a button", "correct label" );
assert.equal( String.prototype.trim.call( buttons.text() ), "a button", "correct label" );
assert.hasClasses( buttons, "additional-class" );
assert.deepEqual( buttons.button( "option", "icon" ), "ui-icon-cancel" );
assert.equal( buttons.button( "option", "showLabel" ), false );
@ -210,22 +210,22 @@ QUnit.test( "closeText", function( assert ) {
assert.expect( 4 );
var element = $( "<div></div>" ).dialog();
assert.equal( $.trim( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "Close",
assert.equal( String.prototype.trim.call( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "Close",
"default close text" );
element.remove();
element = $( "<div></div>" ).dialog( { closeText: "foo" } );
assert.equal( $.trim( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "foo",
assert.equal( String.prototype.trim.call( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "foo",
"closeText on init" );
element.remove();
element = $( "<div></div>" ).dialog().dialog( "option", "closeText", "bar" );
assert.equal( $.trim( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "bar",
assert.equal( String.prototype.trim.call( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "bar",
"closeText via option method" );
element.remove();
element = $( "<div></div>" ).dialog( { closeText: "<span>foo</span>" } );
assert.equal( $.trim( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "<span>foo</span>",
assert.equal( String.prototype.trim.call( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "<span>foo</span>",
"closeText is escaped" );
element.remove();
} );
@ -251,21 +251,25 @@ QUnit.test( "height", function( assert ) {
assert.expect( 4 );
var element = $( "<div></div>" ).dialog();
assert.equal( element.dialog( "widget" ).outerHeight(), 150, "default height" );
assert.ok( Math.abs( element.dialog( "widget" ).outerHeight() - 150 ) < 0.25,
"default height within 0.25 from expected" );
element.remove();
element = $( "<div></div>" ).dialog( { height: 237 } );
assert.equal( element.dialog( "widget" ).outerHeight(), 237, "explicit height" );
assert.ok( Math.abs( element.dialog( "widget" ).outerHeight() - 237 ) < 0.25,
"explicit height within 0.25 from expected" );
element.remove();
element = $( "<div></div>" ).dialog();
element.dialog( "option", "height", 238 );
assert.equal( element.dialog( "widget" ).outerHeight(), 238, "explicit height set after init" );
assert.ok( Math.abs( element.dialog( "widget" ).outerHeight() - 238 ) < 0.25,
"explicit height set after init within 0.25 from expected" );
element.remove();
element = $( "<div></div>" ).css( "padding", "20px" )
.dialog( { height: 240 } );
assert.equal( element.dialog( "widget" ).outerHeight(), 240, "explicit height with padding" );
assert.ok( Math.abs( element.dialog( "widget" ).outerHeight() - 240 ) < 0.25,
"explicit height with padding within 0.25 from expected" );
element.remove();
} );

View File

@ -252,9 +252,9 @@ QUnit.test( "cancelement, default, switching after initialization", function( as
} );
QUnit.test( "connectToSortable, dragging out of a sortable", function( assert ) {
assert.expect( 4 );
assert.expect( 5 );
var sortItem, dragHelper,
var sortItem, dragHelper, result,
element = $( "#draggableSortable" ).draggable( {
scroll: false,
connectToSortable: "#sortable"
@ -280,7 +280,12 @@ QUnit.test( "connectToSortable, dragging out of a sortable", function( assert )
// http://bugs.jqueryui.com/ticket/8809
// Position issue when connected to sortable
assert.deepEqual( ui.helper.offset(), offsetExpected, "draggable offset is correct" );
result = ui.helper.offset();
// Support: Chrome <=45 - 73+
// In recent Chrome these values differ a little.
assert.ok( Math.abs( result.top - offsetExpected.top ) < 0.25, "draggable offset is within 0.25 of expected" );
assert.ok( Math.abs( result.left - offsetExpected.left ) < 0.25, "draggable offset is within 0.25 of expected" );
// Http://bugs.jqueryui.com/ticket/7734
// HTML IDs are removed when dragging to a Sortable

View File

@ -210,7 +210,7 @@ QUnit.test( "animateClass clears style properties when stopped", function( asser
.stop( true, true )
.promise()
.then( function() {
assert.equal( orig, $.trim( style.cssText ), "cssText is the same after stopping animation midway" );
assert.equal( orig, String.prototype.trim.call( style.cssText ), "cssText is the same after stopping animation midway" );
ready();
} );
} );

View File

@ -14,7 +14,7 @@ return $.extend( helper, {
if ( message === undefined ) {
message = lastItem;
}
log.push( $.trim( message ) );
log.push( String.prototype.trim.call( message ) );
},
logOutput: function() {

View File

@ -95,7 +95,7 @@ QUnit.test( "_renderButtonItem()", function( assert ) {
element.selectmenu( "refresh" );
option = element.find( "option:selected" );
assert.equal(
$.trim( button.text() ),
String.prototype.trim.call( button.text() ),
option.text() + element[ 0 ].selectedIndex,
"refresh: button item text"
);
@ -104,7 +104,7 @@ QUnit.test( "_renderButtonItem()", function( assert ) {
menu.find( "li" ).last().simulate( "mouseover" ).trigger( "click" );
option = element.find( "option" ).last();
assert.equal(
$.trim( button.text() ),
String.prototype.trim.call( button.text() ),
option.text() + element[ 0 ].selectedIndex,
"click: button item text"
);
@ -153,7 +153,7 @@ $.each( [
selected.val(),
"original select state"
);
assert.equal( $.trim( button.text() ), selected.text(), "button text" );
assert.equal( String.prototype.trim.call( button.text() ), selected.text(), "button text" );
ready();
} );
} );
@ -189,7 +189,7 @@ $.each( [
selected.val(),
"original select state"
);
assert.equal( $.trim( button.text() ), selected.text(), "button text" );
assert.equal( String.prototype.trim.call( button.text() ), selected.text(), "button text" );
ready();
}, 1 );
} );
@ -231,7 +231,7 @@ $.each( [
"button aria-activedescendant" );
assert.equal( element.find( "option:selected" ).val(), options.eq( 1 ).val(),
"original select state" );
assert.equal( $.trim( button.text() ), options.eq( 1 ).text(), "button text" );
assert.equal( String.prototype.trim.call( button.text() ), options.eq( 1 ).text(), "button text" );
ready();
} );
} );
@ -352,10 +352,10 @@ QUnit.test( "Selectmenu should reset when its parent form resets", function( ass
element.val( "Slower" );
element.selectmenu( "refresh" );
assert.equal( $.trim( widget.text() ), "Slower" );
assert.equal( String.prototype.trim.call( widget.text() ), "Slower" );
form[ 0 ].reset();
setTimeout( function() {
assert.equal( $.trim( widget.text() ), initialValue );
assert.equal( String.prototype.trim.call( widget.text() ), initialValue );
ready();
} );
} );

View File

@ -83,21 +83,21 @@ QUnit.test( "refresh - change selected option", function( assert ) {
var element = $( "#speed" ).selectmenu(),
button = element.selectmenu( "widget" );
assert.equal( $.trim( button.text() ), "Medium", "button text after init" );
assert.equal( String.prototype.trim.call( button.text() ), "Medium", "button text after init" );
button.simulate( "focus" );
setTimeout( function() {
assert.equal( $.trim( button.text() ), "Medium", "button text after focus" );
assert.equal( String.prototype.trim.call( button.text() ), "Medium", "button text after focus" );
element[ 0 ].selectedIndex = 0;
element.selectmenu( "refresh" );
assert.equal( $.trim( button.text() ), "Slower", "button text after changing selected option" );
assert.equal( String.prototype.trim.call( button.text() ), "Slower", "button text after changing selected option" );
element.find( "option" ).prop( "selected", false );
element.append( "<option selected value=\"selected_option\">Selected option</option>" );
element.selectmenu( "refresh" );
assert.equal( $.trim( button.text() ), "Selected option", "button text after adding selected option" );
assert.equal( String.prototype.trim.call( button.text() ), "Selected option", "button text after adding selected option" );
ready();
} );

View File

@ -12,7 +12,10 @@ var versions = [
"2.2.0", "2.2.1", "2.2.2", "2.2.3", "2.2.4",
"3.0.0",
"3.1.0", "3.1.1",
"git", "custom"
"3.2.0", "3.2.1",
"3.3.0", "3.3.1",
"3.4.0", "3.4.1",
"3.x-git", "git", "custom"
],
additionalTests = {

View File

@ -29,7 +29,7 @@ QUnit.test( "widget creation", function( assert ) {
};
$.widget( "ui.testWidget", myPrototype );
assert.ok( $.isFunction( $.ui.testWidget ), "constructor was created" );
assert.ok( typeof $.ui.testWidget === "function", "constructor was created" );
assert.equal( typeof $.ui.testWidget.prototype, "object", "prototype was created" );
method = "_create";
$.ui.testWidget.prototype._create();
@ -947,7 +947,7 @@ QUnit.test( "_on() with delegate", function( assert ) {
this.element = {
on: function( event, handler ) {
assert.equal( event, "click.testWidget" + uuid );
assert.ok( $.isFunction( handler ) );
assert.ok( typeof handler === "function" );
},
trigger: $.noop
};
@ -956,7 +956,7 @@ QUnit.test( "_on() with delegate", function( assert ) {
on: function( event, selector, handler ) {
assert.equal( selector, "a" );
assert.equal( event, "click.testWidget" + uuid );
assert.ok( $.isFunction( handler ) );
assert.ok( typeof handler === "function" );
}
};
};
@ -969,7 +969,7 @@ QUnit.test( "_on() with delegate", function( assert ) {
on: function( event, selector, handler ) {
assert.equal( selector, "form fieldset > input" );
assert.equal( event, "change.testWidget" + uuid );
assert.ok( $.isFunction( handler ) );
assert.ok( typeof handler === "function" );
}
};
};
@ -1608,7 +1608,7 @@ QUnit.test( "$.widget.bridge()", function( assert ) {
$.widget.bridge( "testWidget", TestWidget );
assert.ok( $.isFunction( $.fn.testWidget ), "jQuery plugin was created" );
assert.ok( typeof $.fn.testWidget === "function", "jQuery plugin was created" );
assert.strictEqual( elem.testWidget( { foo: "bar" } ), elem, "plugin returns original jQuery object" );
instance = elem.data( "testWidget" );

View File

@ -7,7 +7,7 @@
<script src="../../../external/requirejs/require.js"></script>
<script src="../../../demos/bootstrap.js">
var start,
html = new Array( 500 ).join( $.trim( $( "#template" ).html() ) );
html = new Array( 500 ).join( String.prototype.trim.call( $( "#template" ).html() ) );
$( html ).appendTo( "body" );
start = new Date();

View File

@ -39,6 +39,8 @@ $.effects = {
effect: {}
};
// jscs:disable
/*!
* jQuery Color Animations v2.1.2
* https://github.com/jquery/jquery-color
@ -716,6 +718,8 @@ colors = jQuery.Color.names = {
} )( jQuery );
// jscs:enable
/******************************************************************************/
/****************************** CLASS ANIMATIONS ******************************/
/******************************************************************************/
@ -1290,7 +1294,7 @@ function _normalizeArguments( effect, options, speed, callback ) {
}
// Catch (effect, callback)
if ( $.isFunction( options ) ) {
if ( typeof options === "function" ) {
callback = options;
speed = null;
options = {};
@ -1304,7 +1308,7 @@ function _normalizeArguments( effect, options, speed, callback ) {
}
// Catch (effect, options, callback)
if ( $.isFunction( speed ) ) {
if ( typeof speed === "function" ) {
callback = speed;
speed = null;
}
@ -1338,7 +1342,7 @@ function standardAnimationOption( option ) {
}
// Complete callback
if ( $.isFunction( option ) ) {
if ( typeof option === "function" ) {
return true;
}
@ -1383,7 +1387,7 @@ $.fn.extend( {
$.effects.saveStyle( el );
}
if ( $.isFunction( next ) ) {
if ( typeof next === "function" ) {
next();
}
};
@ -1418,11 +1422,11 @@ $.fn.extend( {
}
function done() {
if ( $.isFunction( complete ) ) {
if ( typeof complete === "function" ) {
complete.call( elem[ 0 ] );
}
if ( $.isFunction( next ) ) {
if ( typeof next === "function" ) {
next();
}
}
@ -1531,22 +1535,24 @@ $.fn.extend( {
width: target.innerWidth()
},
startPosition = element.offset(),
transfer = $( "<div class='ui-effects-transfer'></div>" )
.appendTo( "body" )
.addClass( options.className )
.css( {
top: startPosition.top - fixTop,
left: startPosition.left - fixLeft,
height: element.innerHeight(),
width: element.innerWidth(),
position: targetFixed ? "fixed" : "absolute"
} )
.animate( animation, options.duration, options.easing, function() {
transfer.remove();
if ( $.isFunction( done ) ) {
done();
}
} );
transfer = $( "<div class='ui-effects-transfer'></div>" );
transfer
.appendTo( "body" )
.addClass( options.className )
.css( {
top: startPosition.top - fixTop,
left: startPosition.left - fixLeft,
height: element.innerHeight(),
width: element.innerWidth(),
position: targetFixed ? "fixed" : "absolute"
} )
.animate( animation, options.duration, options.easing, function() {
transfer.remove();
if ( typeof done === "function" ) {
done();
}
} );
}
} );

View File

@ -48,6 +48,10 @@ function parseCss( element, property ) {
return parseInt( $.css( element, property ), 10 ) || 0;
}
function isWindow( obj ) {
return obj != null && obj === obj.window;
}
function getDimensions( elem ) {
var raw = elem[ 0 ];
if ( raw.nodeType === 9 ) {
@ -57,7 +61,7 @@ function getDimensions( elem ) {
offset: { top: 0, left: 0 }
};
}
if ( $.isWindow( raw ) ) {
if ( isWindow( raw ) ) {
return {
width: elem.width(),
height: elem.height(),
@ -119,12 +123,12 @@ $.position = {
},
getWithinInfo: function( element ) {
var withinElement = $( element || window ),
isWindow = $.isWindow( withinElement[ 0 ] ),
isElemWindow = isWindow( withinElement[ 0 ] ),
isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9,
hasOffset = !isWindow && !isDocument;
hasOffset = !isElemWindow && !isDocument;
return {
element: withinElement,
isWindow: isWindow,
isWindow: isElemWindow,
isDocument: isDocument,
offset: hasOffset ? $( element ).offset() : { left: 0, top: 0 },
scrollLeft: withinElement.scrollLeft(),

View File

@ -60,7 +60,7 @@ $.widget = function( name, base, prototype ) {
base = $.Widget;
}
if ( $.isArray( prototype ) ) {
if ( Array.isArray( prototype ) ) {
prototype = $.extend.apply( null, [ {} ].concat( prototype ) );
}
@ -105,7 +105,7 @@ $.widget = function( name, base, prototype ) {
// inheriting from
basePrototype.options = $.widget.extend( {}, basePrototype.options );
$.each( prototype, function( prop, value ) {
if ( !$.isFunction( value ) ) {
if ( typeof value !== "function" ) {
proxiedPrototype[ prop ] = value;
return;
}
@ -233,7 +233,8 @@ $.widget.bridge = function( name, object ) {
"attempted to call method '" + options + "'" );
}
if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) {
if ( typeof instance[ options ] !== "function" ||
options.charAt( 0 ) === "_" ) {
return $.error( "no such method '" + options + "' for " + name +
" widget instance" );
}
@ -694,7 +695,7 @@ $.Widget.prototype = {
}
this.element.trigger( event, data );
return !( $.isFunction( callback ) &&
return !( typeof callback === "function" &&
callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false ||
event.isDefaultPrevented() );
}

View File

@ -263,7 +263,7 @@ $.widget( "ui.autocomplete", {
// Announce the value in the liveRegion
label = ui.item.attr( "aria-label" ) || item.value;
if ( label && $.trim( label ).length ) {
if ( label && String.prototype.trim.call( label ).length ) {
this.liveRegion.children().hide();
$( "<div>" ).text( label ).appendTo( this.liveRegion );
}
@ -375,7 +375,7 @@ $.widget( "ui.autocomplete", {
_initSource: function() {
var array, url,
that = this;
if ( $.isArray( this.options.source ) ) {
if ( Array.isArray( this.options.source ) ) {
array = this.options.source;
this.source = function( request, response ) {
response( $.ui.autocomplete.filter( array, request.term ) );

View File

@ -373,7 +373,8 @@ if ( $.uiBackCompat !== false ) {
"attempted to call method '" + options + "'" );
}
if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) {
if ( typeof instance[ options ] !== "function" ||
options.charAt( 0 ) === "_" ) {
return $.error( "no such method '" + options + "' for button" +
" widget instance" );
}

View File

@ -234,7 +234,7 @@ return $.widget( "ui.controlgroup", {
var result = {};
$.each( classes, function( key ) {
var current = instance.options.classes[ key ] || "";
current = $.trim( current.replace( controlgroupCornerRegex, "" ) );
current = String.prototype.trim.call( current.replace( controlgroupCornerRegex, "" ) );
result[ key ] = ( current + " " + classes[ key ] ).replace( /\s+/g, " " );
} );
return result;

View File

@ -481,14 +481,14 @@ $.widget( "ui.dialog", {
this.uiDialogButtonPane.remove();
this.uiButtonSet.empty();
if ( $.isEmptyObject( buttons ) || ( $.isArray( buttons ) && !buttons.length ) ) {
if ( $.isEmptyObject( buttons ) || ( Array.isArray( buttons ) && !buttons.length ) ) {
this._removeClass( this.uiDialog, "ui-dialog-buttons" );
return;
}
$.each( buttons, function( name, props ) {
var click, buttonOptions;
props = $.isFunction( props ) ?
props = typeof props === "function" ?
{ click: props, text: name } :
props;

View File

@ -296,7 +296,7 @@ $.widget( "ui.draggable", $.ui.mouse, {
if ( ( this.options.revert === "invalid" && !dropped ) ||
( this.options.revert === "valid" && dropped ) ||
this.options.revert === true || ( $.isFunction( this.options.revert ) &&
this.options.revert === true || ( typeof this.options.revert === "function" &&
this.options.revert.call( this.element, dropped ) )
) {
$( this.helper ).animate(
@ -368,7 +368,7 @@ $.widget( "ui.draggable", $.ui.mouse, {
_createHelper: function( event ) {
var o = this.options,
helperIsFunction = $.isFunction( o.helper ),
helperIsFunction = typeof o.helper === "function",
helper = helperIsFunction ?
$( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
( o.helper === "clone" ?
@ -407,7 +407,7 @@ $.widget( "ui.draggable", $.ui.mouse, {
if ( typeof obj === "string" ) {
obj = obj.split( " " );
}
if ( $.isArray( obj ) ) {
if ( Array.isArray( obj ) ) {
obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
}
if ( "left" in obj ) {

View File

@ -57,7 +57,7 @@ $.widget( "ui.droppable", {
this.isover = false;
this.isout = true;
this.accept = $.isFunction( accept ) ? accept : function( d ) {
this.accept = typeof accept === "function" ? accept : function( d ) {
return d.is( accept );
};
@ -109,7 +109,7 @@ $.widget( "ui.droppable", {
_setOption: function( key, value ) {
if ( key === "accept" ) {
this.accept = $.isFunction( value ) ? value : function( d ) {
this.accept = typeof value === "function" ? value : function( d ) {
return d.is( value );
};
} else if ( key === "scope" ) {

View File

@ -689,7 +689,8 @@ return $.widget( "ui.menu", {
.filter( ".ui-menu-item" )
.filter( function() {
return regex.test(
$.trim( $( this ).children( ".ui-menu-item-wrapper" ).text() ) );
String.prototype.trim.call(
$( this ).children( ".ui-menu-item-wrapper" ).text() ) );
} );
}
} );

View File

@ -261,7 +261,7 @@ $.widget( "ui.resizable", $.ui.mouse, {
for ( i = 0; i < n.length; i++ ) {
handle = $.trim( n[ i ] );
handle = String.prototype.trim.call( n[ i ] );
hname = "ui-resizable-" + handle;
axis = $( "<div>" );
this._addClass( axis, "ui-resizable-handle " + hname );

View File

@ -132,7 +132,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
options.values = [ this._valueMin(), this._valueMin() ];
} else if ( options.values.length && options.values.length !== 2 ) {
options.values = [ options.values[ 0 ], options.values[ 0 ] ];
} else if ( $.isArray( options.values ) ) {
} else if ( Array.isArray( options.values ) ) {
options.values = options.values.slice( 0 );
}
}
@ -395,7 +395,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
}
if ( arguments.length ) {
if ( $.isArray( arguments[ 0 ] ) ) {
if ( Array.isArray( arguments[ 0 ] ) ) {
vals = this.options.values;
newValues = arguments[ 0 ];
for ( i = 0; i < vals.length; i += 1 ) {
@ -429,7 +429,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
}
}
if ( $.isArray( this.options.values ) ) {
if ( Array.isArray( this.options.values ) ) {
valsLength = this.options.values.length;
}

View File

@ -756,7 +756,7 @@ return $.widget( "ui.sortable", $.ui.mouse, {
for ( j = cur.length - 1; j >= 0; j-- ) {
inst = $.data( cur[ j ], this.widgetFullName );
if ( inst && inst !== this && !inst.options.disabled ) {
queries.push( [ $.isFunction( inst.options.items ) ?
queries.push( [ typeof inst.options.items === "function" ?
inst.options.items.call( inst.element ) :
$( inst.options.items, inst.element )
.not( ".ui-sortable-helper" )
@ -766,7 +766,7 @@ return $.widget( "ui.sortable", $.ui.mouse, {
}
}
queries.push( [ $.isFunction( this.options.items ) ?
queries.push( [ typeof this.options.items === "function" ?
this.options.items
.call( this.element, null, { options: this.options, item: this.currentItem } ) :
$( this.options.items, this.element )
@ -806,7 +806,7 @@ return $.widget( "ui.sortable", $.ui.mouse, {
var i, j, cur, inst, targetData, _queries, item, queriesLength,
items = this.items,
queries = [ [ $.isFunction( this.options.items ) ?
queries = [ [ typeof this.options.items === "function" ?
this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) :
$( this.options.items, this.element ), this ] ],
connectWith = this._connectWith();
@ -818,7 +818,7 @@ return $.widget( "ui.sortable", $.ui.mouse, {
for ( j = cur.length - 1; j >= 0; j-- ) {
inst = $.data( cur[ j ], this.widgetFullName );
if ( inst && inst !== this && !inst.options.disabled ) {
queries.push( [ $.isFunction( inst.options.items ) ?
queries.push( [ typeof inst.options.items === "function" ?
inst.options.items
.call( inst.element[ 0 ], event, { item: this.currentItem } ) :
$( inst.options.items, inst.element ), inst ] );
@ -1121,7 +1121,7 @@ return $.widget( "ui.sortable", $.ui.mouse, {
_createHelper: function( event ) {
var o = this.options,
helper = $.isFunction( o.helper ) ?
helper = typeof o.helper === "function" ?
$( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) :
( o.helper === "clone" ? this.currentItem.clone() : this.currentItem );
@ -1155,7 +1155,7 @@ return $.widget( "ui.sortable", $.ui.mouse, {
if ( typeof obj === "string" ) {
obj = obj.split( " " );
}
if ( $.isArray( obj ) ) {
if ( Array.isArray( obj ) ) {
obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
}
if ( "left" in obj ) {

View File

@ -344,7 +344,7 @@ $.widget( "ui.spinner", {
var incremental = this.options.incremental;
if ( incremental ) {
return $.isFunction( incremental ) ?
return typeof incremental === "function" ?
incremental( i ) :
Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
}

View File

@ -95,7 +95,7 @@ $.widget( "ui.tabs", {
// Take disabling tabs via class attribute from HTML
// into account and update option properly.
if ( $.isArray( options.disabled ) ) {
if ( Array.isArray( options.disabled ) ) {
options.disabled = $.uniqueSort( options.disabled.concat(
$.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
return that.tabs.index( li );
@ -502,7 +502,7 @@ $.widget( "ui.tabs", {
_setOptionDisabled: function( disabled ) {
var currentItem, li, i;
if ( $.isArray( disabled ) ) {
if ( Array.isArray( disabled ) ) {
if ( !disabled.length ) {
disabled = false;
} else if ( disabled.length === this.anchors.length ) {
@ -790,7 +790,7 @@ $.widget( "ui.tabs", {
disabled = false;
} else {
index = this._getIndex( index );
if ( $.isArray( disabled ) ) {
if ( Array.isArray( disabled ) ) {
disabled = $.map( disabled, function( num ) {
return num !== index ? num : null;
} );
@ -816,7 +816,7 @@ $.widget( "ui.tabs", {
if ( $.inArray( index, disabled ) !== -1 ) {
return;
}
if ( $.isArray( disabled ) ) {
if ( Array.isArray( disabled ) ) {
disabled = $.merge( [ index ], disabled ).sort();
} else {
disabled = [ index ];

View File

@ -72,7 +72,7 @@ $.widget( "ui.tooltip", {
describedby.push( id );
elem
.data( "ui-tooltip-id", id )
.attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
.attr( "aria-describedby", String.prototype.trim.call( describedby.join( " " ) ) );
},
_removeDescribedBy: function( elem ) {
@ -85,7 +85,7 @@ $.widget( "ui.tooltip", {
}
elem.removeData( "ui-tooltip-id" );
describedby = $.trim( describedby.join( " " ) );
describedby = String.prototype.trim.call( describedby.join( " " ) );
if ( describedby ) {
elem.attr( "aria-describedby", describedby );
} else {