From 98b539171b6e805fa79346a5e9896865e5213b9c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski-Owczarek?= Date: Sun, 8 Dec 2019 22:23:08 +0100 Subject: [PATCH] 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 --- .gitignore | 1 + Gruntfile.js | 80 +- bower.json | 6 + build/tasks/testswarm.js | 4 + demos/autocomplete/xml.html | 3 +- demos/tooltip/video-player.html | 4 +- external/jquery-3.2.0/LICENSE.txt | 36 + external/jquery-3.2.0/jquery.js | 10244 +++++++++++++++ external/jquery-3.2.1/LICENSE.txt | 36 + external/jquery-3.2.1/jquery.js | 10253 +++++++++++++++ external/jquery-3.3.0/LICENSE.txt | 36 + external/jquery-3.3.0/jquery.js | 10364 +++++++++++++++ external/jquery-3.3.1/LICENSE.txt | 36 + external/jquery-3.3.1/jquery.js | 10364 +++++++++++++++ external/jquery-3.4.0/LICENSE.txt | 20 + external/jquery-3.4.0/jquery.js | 10588 +++++++++++++++ external/jquery-3.4.1/LICENSE.txt | 20 + external/jquery-3.4.1/jquery.js | 10598 ++++++++++++++++ .../LICENSE.txt | 2 +- .../jquery-migrate.js | 222 +- tests/lib/bootstrap.js | 8 +- tests/lib/common.js | 4 +- tests/lib/qunit.js | 3 + tests/unit/checkboxradio/options.js | 10 +- tests/unit/core/core.js | 5 +- tests/unit/dialog/deprecated.js | 2 +- tests/unit/dialog/options.js | 22 +- tests/unit/draggable/options.js | 11 +- tests/unit/effects/core.js | 2 +- tests/unit/menu/helper.js | 2 +- tests/unit/selectmenu/core.js | 14 +- tests/unit/selectmenu/methods.js | 8 +- tests/unit/subsuite.js | 5 +- tests/unit/widget/core.js | 10 +- tests/visual/dialog/performance.html | 2 +- ui/effect.js | 50 +- ui/position.js | 12 +- ui/widget.js | 9 +- ui/widgets/autocomplete.js | 4 +- ui/widgets/button.js | 3 +- ui/widgets/controlgroup.js | 2 +- ui/widgets/dialog.js | 4 +- ui/widgets/draggable.js | 6 +- ui/widgets/droppable.js | 4 +- ui/widgets/menu.js | 3 +- ui/widgets/resizable.js | 2 +- ui/widgets/slider.js | 6 +- ui/widgets/sortable.js | 12 +- ui/widgets/spinner.js | 2 +- ui/widgets/tabs.js | 8 +- ui/widgets/tooltip.js | 4 +- 51 files changed, 62977 insertions(+), 179 deletions(-) create mode 100644 external/jquery-3.2.0/LICENSE.txt create mode 100644 external/jquery-3.2.0/jquery.js create mode 100644 external/jquery-3.2.1/LICENSE.txt create mode 100644 external/jquery-3.2.1/jquery.js create mode 100644 external/jquery-3.3.0/LICENSE.txt create mode 100644 external/jquery-3.3.0/jquery.js create mode 100644 external/jquery-3.3.1/LICENSE.txt create mode 100644 external/jquery-3.3.1/jquery.js create mode 100644 external/jquery-3.4.0/LICENSE.txt create mode 100644 external/jquery-3.4.0/jquery.js create mode 100644 external/jquery-3.4.1/LICENSE.txt create mode 100644 external/jquery-3.4.1/jquery.js rename external/{jquery-migrate-3.0.0 => jquery-migrate-3.1.0}/LICENSE.txt (95%) rename external/{jquery-migrate-3.0.0 => jquery-migrate-3.1.0}/jquery-migrate.js (68%) diff --git a/.gitignore b/.gitignore index a8423b607..1c93c0f2a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ dist bower_components node_modules .sizecache.json +package-lock.json diff --git a/Gruntfile.js b/Gruntfile.js index 1aac2c454..78885382f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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 " ] } -}); +} ); 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