Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jquery/jquery-migrate
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7b7573fabcd5ef74d1a3714de3a9923ce820ab1d
Choose a base ref
...
head repository: jquery/jquery-migrate
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e692fe75efebabc05b2354f15bae9704d747d636
Choose a head ref
Loading
Showing with 7,382 additions and 3,589 deletions.
  1. +5 −1 .eslintrc-browser.json
  2. +10 −1 .eslintrc.json
  3. +34 −0 .github/workflows/node.js.yml
  4. +2 −1 .gitignore
  5. +1 −0 .npmignore
  6. +0 −7 .travis.yml
  7. +14 −14 CONTRIBUTING.md
  8. +56 −23 Gruntfile.js
  9. +14 −6 README.md
  10. +0 −7 build/copygit.sh
  11. +27 −10 build/{release.js → release.mjs}
  12. +6,390 −3,062 package-lock.json
  13. +17 −15 package.json
  14. +33 −0 src/disablePatches.js
  15. +31 −7 src/jquery/ajax.js
  16. +9 −7 src/jquery/attributes.js
  17. +50 −36 src/jquery/core.js
  18. +51 −16 src/jquery/css.js
  19. +14 −10 src/jquery/data.js
  20. +9 −7 src/jquery/deferred.js
  21. +14 −7 src/jquery/effects.js
  22. +47 −41 src/jquery/event.js
  23. +16 −10 src/jquery/manipulation.js
  24. +6 −6 src/jquery/offset.js
  25. +8 −6 src/jquery/serialize.js
  26. +3 −7 src/jquery/traversing.js
  27. +44 −12 src/main.js
  28. +1 −1 src/version.js
  29. +3 −20 test/.eslintrc.json
  30. +0 −30 test/ajax.js
  31. +1 −1 test/{ → data}/core-jquery2.html
  32. 0 test/{ → data}/event-fixHooks.html
  33. +1 −1 test/{ → data}/event-lateload.html
  34. 0 test/{ → data}/event-props-concat.html
  35. 0 test/{ → data}/event-props.html
  36. 0 test/{ → data}/event-ready.html
  37. 0 test/{ → data}/iframeTest.js
  38. +50 −0 test/data/test-utils.js
  39. +75 −21 test/{ → data}/testinit.js
  40. +21 −17 test/index.html
  41. +0 −31 test/manipulation-UNSAFE_restoreLegacyHtmlPrefilter.html
  42. +0 −35 test/migrate.js
  43. +121 −0 test/unit/jquery/ajax.js
  44. 0 test/{ → unit/jquery}/attributes.js
  45. +3 −49 test/{ → unit/jquery}/core.js
  46. +17 −4 test/{ → unit/jquery}/css.js
  47. 0 test/{ → unit/jquery}/data.js
  48. 0 test/{ → unit/jquery}/deferred.js
  49. 0 test/{ → unit/jquery}/effects.js
  50. 0 test/{ → unit/jquery}/event.js
  51. +17 −12 test/{ → unit/jquery}/manipulation.js
  52. 0 test/{ → unit/jquery}/offset.js
  53. 0 test/{ → unit/jquery}/serialize.js
  54. 0 test/{ → unit/jquery}/traversing.js
  55. +101 −0 test/unit/migrate.js
  56. +66 −48 warnings.md
6 changes: 5 additions & 1 deletion .eslintrc-browser.json
Original file line number Diff line number Diff line change
@@ -23,6 +23,10 @@

"rules": {
"one-var": [ "error", { "var": "always" } ],
"strict": [ "error", "function" ]
"strict": [ "error", "function" ],

// Support: IE <=9 only, Android <=4.0 only
// Allow square bracket notation for ES3 reserved words
"dot-notation": [ "error", { "allowKeywords": false } ]
}
}
11 changes: 10 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"root": true,

"extends": "./.eslintrc-node.json"
"extends": "./.eslintrc-node.json",

"overrides": [
{
"files": ["**/*.mjs"],
"parserOptions": {
"sourceType": "module"
}
}
]
}
34 changes: 34 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Node.js 10 is required by jQuery infra
NODE_VERSION: [10.x, 16.x]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Cache
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-npm-lock-
- name: Use Node.js ${{ matrix.NODE_VERSION }}
uses: actions/setup-node@v2.1.2
with:
node-version: ${{ matrix.NODE_VERSION }}

- name: Install npm dependencies
run: npm install

- name: Run test
run: npm run ci
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -13,4 +13,5 @@ CDN
/dist/*
!/dist/.eslintrc.json

node_modules
/external
/node_modules
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -7,4 +7,5 @@ coverage
*.patch
/*.html
.DS_Store
external
node_modules
7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

28 changes: 14 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -47,15 +47,15 @@ Make sure you have reproduced the bug with all browser extensions and add-ons di

### Try the latest version of jQuery

Bugs in old versions of jQuery may have already been fixed. In order to avoid reporting known issues, make sure you are always testing against the [latest build](http://code.jquery.com/jquery.js).
Bugs in old versions of jQuery may have already been fixed. In order to avoid reporting known issues, make sure you are always testing against the [latest jQuery version](https://releases.jquery.com/jquery/).

### Try an older version of jQuery

Sometimes, bugs are introduced in newer versions of jQuery that do not exist in previous versions. When possible, it can be useful to try testing with an older release.

### Reduce, reduce, reduce!

When you are experiencing a problem, the most useful thing you can possibly do is to [reduce your code](http://webkit.org/quality/reduction.html) to the bare minimum required to reproduce the issue. This makes it *much* easier to isolate and fix the offending code. Bugs that are reported without reduced test cases take on average 9001% longer to fix than bugs that are submitted with them, so you really should try to do this if at all possible.
When you are experiencing a problem, the most useful thing you can possibly do is to [reduce your code](https://webkit.org/test-case-reduction/) to the bare minimum required to reproduce the issue. This makes it *much* easier to isolate and fix the offending code. Bugs that are reported without reduced test cases take on average 9001% longer to fix than bugs that are submitted with them, so you really should try to do this if at all possible.

## jQuery Core Style Guide

@@ -64,7 +64,7 @@ See: [jQuery Core Style Guide](http://docs.jquery.com/JQuery_Core_Style_Guidelin
## Tips For Bug Patching


### Environment: localhost
### Environment: localhost

To test the plugin you will need:

@@ -84,28 +84,28 @@ Change directory to your web root directory, whatever that might be:
$ cd /path/to/your/www/root/
```

Clone your plugin fork to work locally
Clone your plugin fork to work locally:

```bash
$ git clone git@github.com:username/jquery-migrate.git
```

Change directory to the newly created dir jquery-migrate/
Change directory to the newly created dir `jquery-migrate/`:

```bash
$ cd jquery-migrate
```

Add the jquery-migrate master as a remote. I label mine "upstream"
Add the jquery-migrate repository as a remote; I label mine "upstream":

```bash
$ git remote add upstream git://github.com/jquery/jquery-migrate.git
```

Get in the habit of pulling in the "upstream" master to stay up to date as jQuery receives new commits
Get in the habit of pulling in the "upstream" `main` branch to stay up to date as jQuery Migrate receives new commits:

```bash
$ git pull upstream master
$ git pull upstream main
```

Run the Grunt tools:
@@ -121,14 +121,14 @@ Success! You just built and tested jQuery!

### Fix a bug from a ticket filed at bugs.jquery.com:

**NEVER write your patches to the master branch**
**NEVER write your patches to the `main` branch**

**ALWAYS USE A "TOPIC" BRANCH!** Like so (#### = the ticket #)...

Make sure you start with your up-to-date master:
Make sure you start with your up-to-date `main` branch:

```bash
$ git checkout master
$ git checkout main
```

Create and checkout a new branch that includes the ticket #
@@ -179,16 +179,16 @@ Then, push your branch with the bug fix commits to your github fork
$ git push origin -u bug_####
```

Before you tackle your next bug patch, return to the master:
Before you tackle your next bug patch, return to the `main` branch:

```bash
$ git checkout master
$ git checkout main
```


### Test Suite Tips...

By default the plugin runs against the current (jquery-git WIP) version of jQuery. You can select a different version by specifying it in the URL. Files are always retrieved from code.jquery.com.
By default the plugin runs against the current (jquery-3.x-git WIP) version of jQuery. You can select a different version by specifying it in the URL. Files are always retrieved from code.jquery.com or releases.jquery.com (the latter for development versions).

Example:

79 changes: 56 additions & 23 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -6,29 +6,40 @@ module.exports = function( grunt ) {

const gzip = require( "gzip-js" );

const oldNode = /^v10\./.test( process.version );

const karmaFilesExceptJQuery = [
"external/npo/npo.js",
"dist/jquery-migrate.min.js",
"test/data/compareVersions.js",

"test/testinit.js",
"test/migrate.js",
"test/core.js",
"test/ajax.js",
"test/attributes.js",
"test/css.js",
"test/data.js",
"test/deferred.js",
"test/effects.js",
"test/event.js",
"test/manipulation.js",
"test/offset.js",
"test/serialize.js",
"test/traversing.js",
"test/data/testinit.js",
"test/data/test-utils.js",
"test/unit/migrate.js",
"test/unit/jquery/core.js",
"test/unit/jquery/ajax.js",
"test/unit/jquery/attributes.js",
"test/unit/jquery/css.js",
"test/unit/jquery/data.js",
"test/unit/jquery/deferred.js",
"test/unit/jquery/effects.js",
"test/unit/jquery/event.js",
"test/unit/jquery/manipulation.js",
"test/unit/jquery/offset.js",
"test/unit/jquery/serialize.js",
"test/unit/jquery/traversing.js",

{ pattern: "dist/jquery-migrate.js", included: false, served: true },
{ pattern: "test/**/*.@(js|css|jpg|html|xml)", included: false, served: true }
{ pattern: "test/**/*.@(js|json|css|jpg|html|xml)", included: false, served: true }
];

// Support: Node.js <12
// Skip running tasks that dropped support for Node.js 10
// in this Node version.
function runIfNewNode( task ) {
return oldNode ? "print_old_node_message:" + task : task;
}

// Project configuration.
grunt.initConfig( {
pkg: grunt.file.readJSON( "package.json" ),
@@ -55,6 +66,8 @@ module.exports = function( grunt ) {
"min+3.x-git.min",
"dev+3.x-git.slim",
"min+3.x-git.slim.min",
"dev+3.6.0",
"dev+3.6.0.slim",
"dev+3.5.1",
"dev+3.5.1.slim",
"dev+3.4.1",
@@ -111,6 +124,20 @@ module.exports = function( grunt ) {
]
}
},
npmcopy: {
all: {
options: {
destPrefix: "external"
},
files: {
"npo/npo.js": "native-promise-only/lib/npo.src.js",

"qunit/qunit.js": "qunit/qunit/qunit.js",
"qunit/qunit.css": "qunit/qunit/qunit.css",
"qunit/LICENSE.txt": "qunit/LICENSE.txt"
}
}
},
uglify: {
all: {
files: {
@@ -123,17 +150,17 @@ module.exports = function( grunt ) {
sourceMapName: "dist/jquery-migrate.min.map",
report: "min",
output: {
"ascii_only": true,
ascii_only: true,

// Support: Android 4.0 only
// UglifyJS 3 breaks Android 4.0 if this option is not enabled.
// This is in lieu of setting ie8 for all of mangle, compress, and output
"ie8": true
// This is in lieu of setting ie for all of mangle, compress, and output
ie: true
},
banner: "/*! jQuery Migrate v<%= pkg.version %>" +
" | (c) <%= pkg.author.name %> | jquery.org/license */",
compress: {
"hoist_funs": false,
hoist_funs: false,
loops: false,

// Support: IE <11
@@ -154,7 +181,7 @@ module.exports = function( grunt ) {
},
frameworks: [ "qunit" ],
files: [
"https://code.jquery.com/jquery-3.x-git.min.js",
"https://releases.jquery.com/git/jquery-3.x-git.min.js",
...karmaFilesExceptJQuery
],
client: {
@@ -179,7 +206,7 @@ module.exports = function( grunt ) {

options: {
files: [
"https://code.jquery.com/jquery-3.x-git.slim.min.js",
"https://releases.jquery.com/git/jquery-3.x-git.slim.min.js",
...karmaFilesExceptJQuery
]
}
@@ -212,6 +239,11 @@ module.exports = function( grunt ) {
// Integrate jQuery migrate specific tasks
grunt.loadTasks( "build/tasks" );

grunt.registerTask( "print_old_node_message", ( ...args ) => {
var task = args.join( ":" );
grunt.log.writeln( "Old Node.js detected, running the task \"" + task + "\" skipped..." );
} );

// Just an alias
grunt.registerTask( "test", [
"karma:main",
@@ -224,11 +256,12 @@ module.exports = function( grunt ) {
// would run the dist target first which would point to errors in the built
// file, making it harder to fix them. We want to check the built file only
// if we already know the source files pass the linter.
"eslint:dev",
"eslint:dist"
runIfNewNode( "eslint:dev" ),
runIfNewNode( "eslint:dist" )
] );

grunt.registerTask( "default-no-test", [
"npmcopy",
"build",
"uglify",
"lint",
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/jquery/jquery-migrate.svg?branch=master)](https://travis-ci.org/jquery/jquery-migrate)
![CI Status](https://github.com/jquery/jquery-migrate/actions/workflows/node.js.yml/badge.svg?branch=main)

#### NOTE: To upgrade to jQuery 3.0, you first need version 1.12.x or 2.2.x. If you're using an older version, first upgrade to one of these versions using [jQuery Migrate 1.x](https://github.com/jquery/jquery-migrate/tree/1.x-stable#readme), to resolve any compatibility issues. For more information about the changes made in jQuery 3.0, see the [upgrade guide](https://jquery.com/upgrade-guide/3.0/) and [blog post](https://blog.jquery.com/2016/06/09/jquery-3-0-final-released/).

@@ -12,8 +12,8 @@ That way you can spot and fix what otherwise would have been errors, until you n
In your web page, load this plugin *after* the script tag for jQuery, for example:

```html
<script src="https://code.jquery.com/jquery-3.0.0.js"></script>
<script src="https://code.jquery.com/jquery-migrate-3.3.1.js"></script>
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://code.jquery.com/jquery-migrate-3.4.0.js"></script>
```

## Download
@@ -26,8 +26,8 @@ The production build is minified and does not generate console warnings. It will
|--|-------------|------------|
| Debugging enabled | <p align="center">✓</p> | |
| Minified | | <p align="center">✓</p> |
| Latest release (*may be hotlinked if desired*) | [jquery-migrate-3.3.1.js](https://code.jquery.com/jquery-migrate-3.3.1.js) | [jquery-migrate-3.3.1.min.js](https://code.jquery.com/jquery-migrate-3.3.1.min.js) |
| \* Latest work-in-progress build | [jquery-migrate-git.js](https://code.jquery.com/jquery-migrate-git.js) | [jquery-migrate-git.min.js](https://code.jquery.com/jquery-migrate-git.min.js) |
| Latest release (*may be hotlinked if desired*) | [jquery-migrate-3.4.0.js](https://code.jquery.com/jquery-migrate-3.4.0.js) | [jquery-migrate-3.4.0.min.js](https://code.jquery.com/jquery-migrate-3.4.0.min.js) |
| \* Latest work-in-progress build | [jquery-migrate-git.js](https://releases.jquery.com/git/jquery-migrate-git.js) | [jquery-migrate-git.min.js](https://releases.jquery.com/git/jquery-migrate-git.min.js) |


\* **Work-in-progress build:** Although this file represents the most recent updates to the plugin, it may not have been thoroughly tested. We do not recommend using this file on production sites since it may be unstable; use the released production version instead.
@@ -37,7 +37,7 @@ The production build is minified and does not generate console warnings. It will

The development version of the plugin displays warnings in the browser console. Older browsers such as IE9 doesn't support the console interface. No messages will be generated unless you include a debugging library such as [Firebug Lite](https://getfirebug.com/firebuglite) before including the jQuery Migrate plugin. Developers can also inspect the `jQuery.migrateWarnings` array to see what error messages have been generated.

All warnings generated by this plugin start with the string "JQMIGRATE". A list of the warnings you may see are in [warnings.md](https://github.com/jquery/jquery-migrate/blob/master/warnings.md).
All warnings generated by this plugin start with the string "JQMIGRATE". A list of the warnings you may see are in [warnings.md](https://github.com/jquery/jquery-migrate/blob/main/warnings.md).


## Migrate Plugin API
@@ -56,6 +56,14 @@ This plugin adds some properties to the `jQuery` object that can be used to prog

`jQuery.migrateDeduplicateWarnings`: By default, Migrate only gives a specific warning once. If you set this property to `false` it will give a warning for every occurrence each time it happens. Note that this can generate a lot of output, for example when a warning occurs in a loop.

`jQuery.migrateDisablePatches`: Disables patches by their codes. You can find a code for each patch in square brackets in [warnings.md](https://github.com/jquery/jquery-migrate/blob/main/warnings.md). A limited number of warnings doesn't have codes defined and cannot be disabled. These are mostly setup issues like using an incorrect version of jQuery or loading Migrate multiple times.

`jQuery.migrateDisablePatches`: Disables patches by their codes.

`jQuery.migrateIsPatchEnabled`: Returns `true` if a patch of a provided code is enabled and `false` otherwise.

`jQuery.UNSAFE_restoreLegacyHtmlPrefilter`: A deprecated alias of `jQuery.migrateEnablePatches( "self-closed-tags" )`

## Reporting problems

Bugs that only occur when the jQuery Migrate plugin is used should be reported in the [jQuery Migrate Issue Tracker](https://github.com/jquery/jquery-migrate/issues) and should be accompanied by an executable test case that demonstrates the bug. The easiest way to do this is via an online test tool such as [jsFiddle.net](https://jsFiddle.net/) or [jsbin.com](https://jsbin.com). Use the development version when you are reporting bugs.
7 changes: 0 additions & 7 deletions build/copygit.sh

This file was deleted.

Loading