]> source.dussan.org Git - jquery.git/log
jquery.git
2 years agoTests: Workaround an XML parsing bug in Firefox
Michał Gołębiowski-Owczarek [Mon, 28 Feb 2022 17:26:53 +0000 (18:26 +0100)]
Tests: Workaround an XML parsing bug in Firefox

See https://bugzilla.mozilla.org/show_bug.cgi?id=1751796

Closes gh-5018

2 years agoDocs: add link to preview the new CLAs
Timmy Willison [Mon, 31 Jan 2022 22:20:23 +0000 (17:20 -0500)]
Docs: add link to preview the new CLAs

Close gh-5009

2 years agoCSS: Skip falsy values in `addClass( array )`, compress code
Michał Gołębiowski-Owczarek [Mon, 24 Jan 2022 17:56:49 +0000 (18:56 +0100)]
CSS: Skip falsy values in `addClass( array )`, compress code

This change makes jQuery skip falsy values in `addClass( array )`
& `removeClass( array )` instead of stopping iteration when the first falsy
value is detected. This makes code like:
```js
elem.addClass( [ "a", "", "b" ] );
```
add both the `a` & `b` classes.

The code was also optimized for size a bit so it doesn't increase the
minified gzipped size.

Fixes gh-4998
Closes gh-5003

2 years agoCore: Don't rely on splice being present on input
Bruno PIERRE [Mon, 24 Jan 2022 17:55:16 +0000 (18:55 +0100)]
Core: Don't rely on splice being present on input

Without this fix calling `jQuery.uniqueSort` on an array-like can result in:

TypeError: results.splice is not a function
    at Function.jQuery.uniqueSort (https://code.jquery.com/jquery-git.js:664:12)
    at jQuery.fn.init.find (https://code.jquery.com/jquery-git.js:2394:27)
    at gocusihafe.js:3:4

Closes gh-4986

2 years agoDocs: Fix incorrect `trac-NUMBER` references
Michał Gołębiowski-Owczarek [Wed, 12 Jan 2022 22:23:42 +0000 (23:23 +0100)]
Docs: Fix incorrect `trac-NUMBER` references

PR gh-4993 changed a few too many issue references to `trac-NUMBER` ones. This
change fixes them. It also fixes a typo in one Trac issue number in selector
tests.

Ref gh-4993
Closes gh-4995

2 years agoTests: lock colors version to 1.4.0
Timmy Willison [Mon, 10 Jan 2022 17:54:02 +0000 (12:54 -0500)]
Tests: lock colors version to 1.4.0

2 years agoDocs: remove expired links from old jquery source (#4997)
Timmy Willison [Fri, 7 Jan 2022 17:44:51 +0000 (17:44 +0000)]
Docs: remove expired links from old jquery source (#4997)

Ref gh-4981
Ref gh-4991

2 years agoDocs: Remove links to Web Archive from source
Michał Gołębiowski-Owczarek [Tue, 4 Jan 2022 15:33:43 +0000 (16:33 +0100)]
Docs: Remove links to Web Archive from source

Neither of the removed links is crucial; one of them refers to a site that has
since started being malicious; while the Web Archive links remain safe, some
scanners warn about such links. Removing them is the safest thing to do.

Fixes gh-4981
Closes gh-4991

2 years agoBuild: Separate the install step from running tests in GitHub Actions
Michał Gołębiowski-Owczarek [Tue, 4 Jan 2022 15:27:42 +0000 (16:27 +0100)]
Build: Separate the install step from running tests in GitHub Actions

Also, update the "Run test" label to "Run tests".

Closes gh-4992

2 years agoDocs: Replace `#NUMBER` Trac issue references with `trac-NUMBER`
Michał Gołębiowski-Owczarek [Tue, 4 Jan 2022 15:27:18 +0000 (16:27 +0100)]
Docs: Replace `#NUMBER` Trac issue references with `trac-NUMBER`

The GitHub UI treats `#NUMBER` as referring to its own issues which is confusing
when in jQuery source it's usually referring to the old deprecated Trac instance
at https://bugs.jquery.com. This change replaces all such Trac references with
`trac-NUMBER`.

A few of the references came with the Sizzle integration and referred to the
Sizzle GitHub bug tracker. Those have been replaced with full links instead.

A new entry describing issue reference conventions has been added to README.

Closes gh-4993

2 years agoCSS: Justify use of rtrim on CSS property values
Richard Gibson [Mon, 3 Jan 2022 12:28:49 +0000 (07:28 -0500)]
CSS: Justify use of rtrim on CSS property values

CSS does not acknowledge carriage return or form feed characters
as whitespace but it does replace them with whitespace, making it
acceptable to use `rtrim`.

Closes gh-4956

2 years agoBuild: remove travis.yml and travis mentions from core (#4983)
Timmy Willison [Mon, 13 Dec 2021 17:22:52 +0000 (12:22 -0500)]
Build: remove travis.yml and travis mentions from core (#4983)

We've migrated to GH actions on jQuery core and have already disabled travis builds for core.

2 years agoTests: Skip ETag AJAX tests on TestSwarm
Michał Gołębiowski-Owczarek [Wed, 1 Dec 2021 11:46:33 +0000 (12:46 +0100)]
Tests: Skip ETag AJAX tests on TestSwarm

TestSwarm is now proxied via Cloudflare which cuts out headers relevant for
ETag tests, failing them. We're still running those tests in Karma on Chrome
& Firefox (including Firefox ESR).

Closes gh-4974

2 years agoTests: Allow statusText to be "success" in AJAX tests
Michał Gołębiowski-Owczarek [Wed, 1 Dec 2021 11:46:17 +0000 (12:46 +0100)]
Tests: Allow statusText to be "success" in AJAX tests

In HTTP/2, status message is not supported and whatever is reported as
statusText differs between browsers. In Chrome & Safari it's "success", in
Firefox & IE it's "OK". So far "success" wasn't allowed. This made the tests
pass locally if you're running an HTTP/1.1 server but on TestSwarm which is
now proxied via an HTTP/2-equipped Cloudflare, the relevant test started failing
in Chrome & Safari.

Allow "success" to resolve the issue.

Closes gh-4973

2 years agoBuild: Migrate CI to GitHub Actions
ygj6 [Tue, 30 Nov 2021 22:56:39 +0000 (06:56 +0800)]
Build: Migrate CI to GitHub Actions

Closes gh-4800

2 years agoDocs: Update the URL to the latest jQuery build in CONTRIBUTING.md
Michał Gołębiowski-Owczarek [Thu, 18 Nov 2021 21:54:34 +0000 (22:54 +0100)]
Docs: Update the URL to the latest jQuery build in CONTRIBUTING.md

It used to say https://code.jquery.com/jquery.js but that's a frozen URL
to jQuery 1.11.1. Let's switch that to the URL to the Git build, i.e.
https://releases.jquery.com/git/jquery-git.js.

Closes gh-4972

2 years agoAttributes: Don't stringify attributes in the setter
Michał Gołębiowski-Owczarek [Mon, 1 Nov 2021 17:10:23 +0000 (18:10 +0100)]
Attributes: Don't stringify attributes in the setter

Stringifying attributes in the setter was needed for IE <=9 but it breaks
trusted types enforcement when setting a script `src` attribute.

Note that this doesn't mean script execution works. Since jQuery disables all
scripts by changing their type and then executes them by creating fresh script
tags with proper `src` & possibly other attributes, this unwraps any trusted
`src` wrappers, making the script not execute under strict CSP settings.
We might try to fix it in the future in a separate change.

Fixes gh-4948
Closes gh-4949

2 years agoTests: Make Karma browser timeout larger than the QUnit one
Michał Gołębiowski-Owczarek [Fri, 29 Oct 2021 22:56:31 +0000 (00:56 +0200)]
Tests: Make Karma browser timeout larger than the QUnit one

Since the default Karma browser no activity timeout was lower than the QUnit
timeout, a single timing out test was interrupting the whole test run of
a browser.

The QUnit timeout is set to 1 minute so I set the Karma one to 2 minutes.

Closes gh-4943

2 years agoBuild: Update ESLint & eslint-plugin-import, fixing the build
Michał Gołębiowski-Owczarek [Fri, 29 Oct 2021 21:43:13 +0000 (23:43 +0200)]
Build: Update ESLint & eslint-plugin-import, fixing the build

Latest `main` started failing the build after some transitive dependencies
got updated, incorrectly recognizing some files with default exports as unused.

Since the new ESLint no longer supports Node 10 which we have to build on due
to use in our CI, skip ESLint in Node 10.

Ref gh-3225
Closes gh-4961

2 years agoDocs: Remove the CLA checkbox in the pull request template
Michał Gołębiowski-Owczarek [Mon, 18 Oct 2021 16:09:04 +0000 (18:09 +0200)]
Docs: Remove the CLA checkbox in the pull request template

The EasyCLA status check is required so this won't get missed. The old JSF CLA
is dead, the provided link doesn't return meaningful information. There's no
good replacement link for the old CLA; PR authors are just supposed to sign the
new CLA by clicking on a link posted by the EasyCLA bot when they submit their
first PR since EasyCLA was enabled for the repo.

Closes gh-4937

3 years agoCore:Manipulation: Add basic TrustedHTML support
Michał Gołębiowski-Owczarek [Thu, 30 Sep 2021 14:00:24 +0000 (16:00 +0200)]
Core:Manipulation: Add basic TrustedHTML support

This ensures HTML wrapped in TrustedHTML can be used as an input to jQuery
manipulation methods in a way that doesn't violate the
`require-trusted-types-for` Content Security Policy directive.
This commit builds on previous work needed for trusted types support, including
gh-4642 and gh-4724.

One restriction is that while any TrustedHTML wrapper should work as input
for jQuery methods like `.html()` or `.append()`, for passing directly to the
`jQuery` factory the string must start with `<` and end with `>`; no trailing
or leading whitespaces are allowed. This is necessary as we cannot parse out
a part of the input for further construction; that would violate the CSP rule -
and that's what's done to HTML input not matching these constraints.

No trusted types API is used explicitly in source; the majority of the work is
ensuring we don't pass the input converted to string to APIs that would
eventually assign it to `innerHTML`. This extra cautiousness is caused by the
API being Blink-only, at least for now.

The ban on passing strings to `innerHTML` means support tests relying on such
assignments are impossible. We don't currently have such tests on the `main`
branch but we used to have many of them in the 3.x & older lines. If there's
a need to re-add such a test, we'll need an escape hatch to skip them for apps
needing CSP-enforced TrustedHTML.

See https://web.dev/trusted-types/ for more information about TrustedHTML.

Fixes gh-4409
Closes gh-4927
Ref gh-4642
Ref gh-4724

3 years agoTests: Don't remove csp.log in the cspClean action of mock.php
Michał Gołębiowski-Owczarek [Wed, 29 Sep 2021 22:08:47 +0000 (00:08 +0200)]
Tests: Don't remove csp.log in the cspClean action of mock.php

For some reason the current setup worked fine with Apache but broke for me when
I migrated to nginx.

Closes gh-4936

3 years agoTests: Load the TestSwarm listener via HTTPS
Michał Gołębiowski-Owczarek [Wed, 29 Sep 2021 13:28:52 +0000 (15:28 +0200)]
Tests: Load the TestSwarm listener via HTTPS

3 years agoCSS: Trim whitespace surrounding CSS Custom Properties values
fecore1 [Thu, 23 Sep 2021 11:35:18 +0000 (19:35 +0800)]
CSS: Trim whitespace surrounding CSS Custom Properties values

The spec has recently changed and CSS Custom Properties values are trimmed now.
This change makes jQuery polyfill that new behavior for all browsers.

Ref w3c/csswg-drafts#774
Fixes gh-4926
Closes gh-4930

3 years agoDocs: update irc to Libera and fix LAMP dead link
fecore1 [Sun, 5 Sep 2021 19:23:59 +0000 (03:23 +0800)]
Docs: update irc to Libera and fix LAMP dead link

3 years agoManipulation: Don't remove HTML comments from scripts
Michał Gołębiowski-Owczarek [Mon, 19 Jul 2021 17:04:23 +0000 (19:04 +0200)]
Manipulation: Don't remove HTML comments from scripts

When evaluating scripts, jQuery strips out the possible wrapping HTML comment
and a CDATA section. However, all supported browsers are already doing that
when loading JS via appending a script tag to the DOM which is how we've been
doing `jQuery.globalEval` since jQuery 3.0.0. jQuery logic was imperfect, e.g.
it just stripped the `<!--` and `-->` markers, respectively at the beginning or
the end of the script contents. However, browsers are also stripping everything
following those markers in the same line, treating them as single-line comments
delimiters; this is now also mandated by ECMAScript 2015 in Annex B. Instead
of fixing the jQuery logic, just let the browser do its thing.

We also used to strip CDATA sections. However, this shouldn't be needed as in
XML documents they're already not visible when inspecting element contents and
in HTML documents they have no meaning. We've preserved that behavior for
backwards compatibility in 3.x but we're removing it for 4.0.

Fixes gh-4904
Closes gh-4906

3 years agoBuild: Test on Node.js 16 instead of 15
Michał Gołębiowski-Owczarek [Mon, 12 Jul 2021 16:34:56 +0000 (18:34 +0200)]
Build: Test on Node.js 16 instead of 15

Node.js 10 is kept for now despite being EOL'd as that's what our current
infrastructure relies on.

Closes gh-4902

3 years agoTests: Switch background image from online file to local 1x1.jpg
Timo Tijhof [Mon, 24 May 2021 16:23:50 +0000 (17:23 +0100)]
Tests: Switch background image from online file to local 1x1.jpg

Also, remove unused `expected` property in `css` test cases.

Closes gh-4866

3 years agoEvent: Don't break focus triggering after `.on(focus).off(focus)`
Michał Gołębiowski-Owczarek [Mon, 10 May 2021 16:59:14 +0000 (18:59 +0200)]
Event: Don't break focus triggering after `.on(focus).off(focus)`

The `_default` function in the special event settings for focus/blur has
always returned `true` since gh-4813 as the event was already being fired
from `leverageNative`. However, that only works if there's an active handler
on that element; this made a quick consecutive call:

```js
elem.on( "focus", function() {} ).off( "focus" );
```

make subsequent `.trigger( "focus" )` calls to not do any triggering.

The solution, already used in a similar `_default` method for the `click` event,
is to check for the `dataPriv` entry on the element for the focus event
(similarly for blur).

Fixes gh-4867
Closes gh-4885

3 years agoTests: Strip untypical callback parameter characters from mock.php
Michał Gołębiowski-Owczarek [Tue, 13 Apr 2021 20:13:48 +0000 (22:13 +0200)]
Tests: Strip untypical callback parameter characters from mock.php

Only allow alphanumeric characters & underscores for callback parameters.
The change is done both for the PHP server as well as the Node.js-based version.
This is only test code so we're not fixing any security issue but it happens
often enough that the whole jQuery repository directory structure is deployed
onto the server with PHP enabled that it makes is easy to introduce security
issues if this cleanup is not done.

Ref gh-4764
Closes gh-4871

3 years agoTests: Make more tests run natively in Chrome & Firefox
Michał Gołębiowski-Owczarek [Tue, 13 Apr 2021 20:11:45 +0000 (22:11 +0200)]
Tests: Make more tests run natively in Chrome & Firefox

Chrome & Firefox now support complex `:not()` selectors so those test can run
in them even without custom jQuery selector code. In the past, it was only
possible in Safari, now we only need to exclude IE.

Closes gh-4864

3 years agoBuild: Take core-js-bundle from the external directory as well
Michał Gołębiowski-Owczarek [Tue, 13 Apr 2021 20:10:09 +0000 (22:10 +0200)]
Build: Take core-js-bundle from the external directory as well

That package was missed in gh-4865 as it only broke browsers needing the
polyfill which is just IE at the moment. Thus, it broke Core tests in IE only.

Ref gh-4865
Closes gh-4870

3 years agoBuild: Restore the external directory
Michał Gołębiowski-Owczarek [Wed, 24 Mar 2021 22:36:25 +0000 (23:36 +0100)]
Build: Restore the external directory

In gh-4466, we removed the `external` directory in favor of loading some files
directly from `node_modules`. This works fine locally but when deploying code
for tests, this makes it impossible to not deploy `node_modules` as well. To
avoid the issue, this change restores usage of the `external` directory.

One change is that we no longer commit this directory to the repository, its
only purpose is to have clear isolation from `node_modules`.

Ref gh-4466
Closess gh-4865

3 years agoRelease: remove the need to install grunt globally
Timmy Willison [Mon, 1 Mar 2021 22:48:55 +0000 (17:48 -0500)]
Release: remove the need to install grunt globally

3 years agoRelease: upgrade release dependencies
Timmy Willison [Mon, 1 Mar 2021 21:48:41 +0000 (16:48 -0500)]
Release: upgrade release dependencies

- Remove unused npm dependency

3 years agoSupport: ensure display is set to block for the support div
Timmy Willison [Wed, 17 Feb 2021 21:19:04 +0000 (16:19 -0500)]
Support: ensure display is set to block for the support div

* Support: ensure display is set to block for the support div

- Fixes an issue with the support test in iframes in Android 8 Chrome 86+,
  where display: inline resulted in unexpected height values.

Close gh-4845
Fixes gh-4832

3 years agoBuild: Rename master to main across the repository
Michał Gołębiowski-Owczarek [Fri, 5 Feb 2021 21:00:56 +0000 (22:00 +0100)]
Build: Rename master to main across the repository

The default branch was updated, this updates the remaining occurrences in code
& comments.

Closes gh-4838

3 years agoAjax: Don't auto-execute scripts unless dataType provided
Michał Gołębiowski-Owczarek [Tue, 26 Jan 2021 14:58:29 +0000 (15:58 +0100)]
Ajax: Don't auto-execute scripts unless dataType provided

PR gh-2588 made jQuery stop auto-execute cross-domain scripts unless
`dataType: "script"` was explicitly provided; this change landed in jQuery
3.0.0. This change extends that logic same-domain scripts as well.

After this change, to request a script under a provided URL to be evaluated,
you need to provide `dataType: "script` in `jQuery.ajax` options or to use
`jQuery.getScript`.

Fixes gh-4822
Closes gh-4825
Ref gh-2432
Ref gh-2588

3 years agoDeferred: Rename master to primary
Michał Gołębiowski-Owczarek [Tue, 12 Jan 2021 19:56:51 +0000 (20:56 +0100)]
Deferred: Rename master to primary

Closes gh-4828

3 years agoTests: Fix tests for not auto-executing scripts without dataType
Michał Gołębiowski-Owczarek [Mon, 11 Jan 2021 17:20:36 +0000 (18:20 +0100)]
Tests: Fix tests for not auto-executing scripts without dataType

Two issues are fixed in testing for responses with a script Content-Type not
getting auto-executed unless an explicit `dataType: "script"` is provided:
* the test is now using a correct "text/javascript" Content-Type; it was using
  "text/html" until now which doesn't really check if the fix works
* the Node.js based version of the tests didn't account for an empty `header`
  query string parameter

Closes gh-4824
Ref gh-2432
Ref gh-2588
Ref 39cdb8c9aa0fde68f733553ba050a2ba9d86474c

3 years agoDimensions: Add offset prop fallback to FF for unreliable TR dimensions
Timmy Willison [Mon, 11 Jan 2021 16:56:08 +0000 (11:56 -0500)]
Dimensions: Add offset prop fallback to FF for unreliable TR dimensions

Firefox incorrectly (or perhaps correctly) includes table borders in computed
dimensions, but they are the only one. Workaround this by testing for it and
falling back to offset properties

Fixes gh-4529
Closes gh-4808

3 years agoCore: Report browser errors in parseXML
Michał Gołębiowski-Owczarek [Tue, 8 Dec 2020 10:22:21 +0000 (11:22 +0100)]
Core: Report browser errors in parseXML

Fixes gh-4784
Closes gh-4816

3 years agoCore: Make jQuery.isXMLDoc accept falsy input
Michał Gołębiowski-Owczarek [Mon, 7 Dec 2020 20:09:15 +0000 (21:09 +0100)]
Core: Make jQuery.isXMLDoc accept falsy input

Fixes gh-4782
Closes gh-4814

3 years agoEvent: Make focus re-triggering not focus the original element back
Michał Gołębiowski-Owczarek [Mon, 7 Dec 2020 19:28:44 +0000 (20:28 +0100)]
Event: Make focus re-triggering not focus the original element back

If during a focus handler another focus event is triggered:

```js
elem1.on( "focus", function() {
elem2.trigger( "focus" );
} );
```

due to their synchronous nature everywhere outside of IE the hack added in
gh-4279 to leverage native events causes the native `.focus()` method to be
called last for the initial element, making it steal the focus back. Since
the native method is already being called in `leverageNative`, we can skip that
final call.

This aligns with changes to the `_default` method for the `click` event that
were added when `leverageNative` was introduced there.

A side effect of this change is that now `focusin` will only propagate to the
document for the last focused element. This is a change in behavior but it also
aligns us better with how this works with native methods.

Fixes gh-4382
Closes gh-4813
Ref gh-4279

3 years agoBuild: Test on Node.js 15
Michał Gołębiowski-Owczarek [Wed, 11 Nov 2020 22:02:22 +0000 (23:02 +0100)]
Build: Test on Node.js 15

Also, run browser tests on Node 14 instead of 12.

Closes gh-4802

3 years agoEvent: Don't crash if an element is removed on blur
Michał Gołębiowski-Owczarek [Mon, 19 Oct 2020 19:17:51 +0000 (21:17 +0200)]
Event: Don't crash if an element is removed on blur

In Chrome, if an element having a `focusout` handler is blurred by
clicking outside of it, it invokes the handler synchronously. If
that handler calls `.remove()` on the element, the data is cleared,
leaving private data undefined. We're reading a property from that
data so we need to guard against this.

Fixes gh-4417
Closes gh-4799

4 years agoBuild: Explicitly exclude the queue module from the slim build
Michał Gołębiowski-Owczarek [Mon, 28 Sep 2020 16:33:33 +0000 (18:33 +0200)]
Build: Explicitly exclude the queue module from the slim build

The queue module is not present in the slim build as it depends on deferred
and our Gruntfile specifies excluding deferred should also exclude queue:
https://github.com/jquery/jquery/blob/3.5.1/Gruntfile.js#L66
This commit makes this exclusion explicit so that the queue module never
accidentally gets re-included in the slim build if it stopped importing from
the deferred module directly.

Closes gh-4793

4 years agoCore: Drop support for Edge Legacy (i.e. non-Chromium Microsoft Edge)
Michał Gołębiowski-Owczarek [Tue, 22 Sep 2020 15:49:28 +0000 (17:49 +0200)]
Core: Drop support for Edge Legacy (i.e. non-Chromium Microsoft Edge)

Drop support for Edge Legacy: the non-Chromium, EdgeHTML-based Microsoft
Edge version. Also, restrict some workarounds that were applied
unconditionally in all browsers to run only in IE now. This slightly
increases the size but reduces the performance burden on modern browsers
that don't need the workarounds.

Also, clean up some comments & remove some obsolete workarounds.

Fixes gh-4568
Closes gh-4792

4 years agoManipulation: Respect script crossorigin attribute in DOM manipulation
高灰 [Tue, 22 Sep 2020 15:30:18 +0000 (23:30 +0800)]
Manipulation: Respect script crossorigin attribute in DOM manipulation

Fixes gh-4542
Closes gh-4563

Co-authored-by: Michał Gołębiowski-Owczarek <m.goleb@gmail.com>
4 years agoTests: Recognize callbacks with dots in the Node.js mock server 4785/head
Michał Gołębiowski-Owczarek [Wed, 2 Sep 2020 16:42:52 +0000 (18:42 +0200)]
Tests: Recognize callbacks with dots in the Node.js mock server

This aligns the Node.js server with the previous PHP one in sending `mock.php`
as a callback if there's no `callback` parameter in the query string which is
triggered by a recently added test. This prevents the request crashing on that
Node.js server and printing a JS error:
```
TypeError: Cannot read property '1' of null
```

Closes gh-4764
Ref gh-4754

4 years agoTests: Skip the "jQuery.ajax() on unload" test in Safari
Michał Gołębiowski-Owczarek [Wed, 2 Sep 2020 16:04:44 +0000 (18:04 +0200)]
Tests: Skip the "jQuery.ajax() on unload" test in Safari

The test has been already skipped in Chrome as it dropped support for such
requests and now Safari has joined the squad.

This will resolve AJAX test errors we've had for a while in Safari 13 & iOS 13.

Closes gh-4779

4 years agoBuild: Make the import/no-unused-modules ESLint rule work in WebStorm
Michał Gołębiowski-Owczarek [Wed, 2 Sep 2020 15:24:55 +0000 (17:24 +0200)]
Build: Make the import/no-unused-modules ESLint rule work in WebStorm

When run via WebStorm, the root path against which paths in the config of the
`import/no-unused-modules` ESLint rule are resolved is the path where the ESLint
config file that defines the rule lies, i.e. `src`. When run via the command
line, it's usually the root folder of the jQuery repository. This pattern
intends to catch both.

Note that we cannot specify two patterns here:
```js
[ "src/*.js", "*.js" ]
```
as they're analyzed individually and the rule crashes if a pattern cannot be
matched.

Closes gh-4777

4 years agoAttributes: Drop the `toggleClass(boolean|undefined)` signature
Michał Gołębiowski-Owczarek [Tue, 1 Sep 2020 08:42:03 +0000 (10:42 +0200)]
Attributes: Drop the `toggleClass(boolean|undefined)` signature

The behavior of this signature is not intuitive, especially if classes are
manipulated via other ways between `toggleClass` calls.

Fixes gh-3388
Closes gh-4766

4 years agoAjax: Make responseJSON work for erroneous same-domain JSONP requests
Michał Gołębiowski-Owczarek [Mon, 31 Aug 2020 22:02:44 +0000 (00:02 +0200)]
Ajax: Make responseJSON work for erroneous same-domain JSONP requests

Don't use a script tag for JSONP requests unless for cross-domain requests
or if scriptAttrs are provided. This makes the `responseJSON` property available
in JSONP error callbacks.

This fixes a regression from jQuery 3.5.0 introduced in gh-4379 which made
erroneous script responses to not be executed to follow native behavior.

The 3.x-stable branch doesn't need this fix as it doesn't use script tags for
regular async requests.

Closes gh-4778
Ref gh-4771
Ref gh-4773
Ref gh-4379

4 years agoEvent: Remove the event.which shim
Michał Gołębiowski-Owczarek [Wed, 26 Aug 2020 12:10:33 +0000 (14:10 +0200)]
Event: Remove the event.which shim

All supported browsers implement this property by themselves. The shim was only
needed for IE <9.

Fixes gh-3235
Closes gh-4765
Ref gh-4755

4 years agoAjax: Execute JSONP error script responses
Dallas Fraser [Tue, 25 Aug 2020 19:41:06 +0000 (15:41 -0400)]
Ajax: Execute JSONP error script responses

Issue gh-4379 was meant to be a bug fix but the JSONP case is a bit special:
under the hood it's a script but it simulates JSON responses in an environment
without a CORS setup and sending JSON payloads on error responses is quite
typical there.

This commit makes JSONP error responses still execute the payload. The regular
script error responses continue to be skipped.

Fixes gh-4771
Closes gh-4773

4 years agoAjax: Avoid CSP errors in the script transport for async requests
Michał Gołębiowski-Owczarek [Tue, 25 Aug 2020 19:28:30 +0000 (21:28 +0200)]
Ajax: Avoid CSP errors in the script transport for async requests

Until now, the AJAX script transport only used a script tag to load scripts
for cross-domain requests or ones with `scriptAttrs` set. This commit makes
it also used for all async requests to avoid CSP errors arising from usage
of inline scripts. This also makes `jQuery.getScript` not trigger CSP errors
as it uses the AJAX script transport under the hood.

For sync requests such a change is impossible and that's what `jQuery._evalUrl`
uses. Fixing that is tracked in gh-1895.

The commit also makes other type of requests using the script tag version of the
script transport set its type to "GET", namely async scripts & ones with
`scriptAttrs` set in addition to the existing cross-domain ones.

Fixes gh-3969
Closes gh-4763

4 years agoTests: Remove an unused local variable
Wonhyoung Park [Thu, 13 Aug 2020 11:24:30 +0000 (20:24 +0900)]
Tests: Remove an unused local variable

Closes gh-4769

4 years agoBuild: Append .eslintignore paths to grunt eslint paths
Ed Sanders [Tue, 21 Apr 2020 11:43:52 +0000 (12:43 +0100)]
Build: Append .eslintignore paths to grunt eslint paths

This allows us to turn off the `quiet` option which was suppressing warnings.
We can also set `maxWarnings` to 0 now that aren't any.

Closes gh-4689

4 years agoAjax: Drop the json to jsonp auto-promotion logic
Michał Gołębiowski-Owczarek [Mon, 27 Jul 2020 17:15:57 +0000 (19:15 +0200)]
Ajax: Drop the json to jsonp auto-promotion logic

Previously, `jQuery.ajax` with `dataType: 'json'` with a provided callback was
automatically converted to a jsonp request unless one also specified
`jsonp: false`. Today the preferred way of interacting with a cross-domain
backend is CORS which works in all browsers jQuery 4 will support.

Auto-promoting JSON requests to JSONP ones introduces a security issue as the
developer may be unaware they're not just downloading data but executing code
from a remote domain.

This commit disables the auto-promoting logic.

BREAKING CHANGE: to trigger a JSONP request, it's now required to specify
`dataType: "jsonp"`; previously some requests with `dataType: "json"` were
auto-promoted to JSONP.

Fixes gh-1799
Fixes gh-3376
Closes gh-4754

4 years agoBuild: Use the US spelling of "favor"
Necmettin Karakaya [Wed, 22 Jul 2020 14:12:54 +0000 (22:12 +0800)]
Build: Use the US spelling of "favor"

Closes gh-4752

4 years agoBuild: Fix commitplease husky config
Beatriz Rezener [Mon, 20 Jul 2020 17:06:39 +0000 (14:06 -0300)]
Build: Fix commitplease husky config

Fixes gh-4735
Closes gh-4737

4 years agoBuild: Update dependencies
Michał Gołębiowski-Owczarek [Wed, 15 Jul 2020 14:17:41 +0000 (16:17 +0200)]
Build: Update dependencies

This also resolves a security warning from GitHub about a vulnerable `request`
version - the new `testswarm` package version depends on a fixed `request`.

Closes gh-4732

4 years agobuild: set up periodic code scanning analysis
Timmy Willison [Thu, 25 Jun 2020 21:32:02 +0000 (17:32 -0400)]
build: set up periodic code scanning analysis

4 years agoManipulation: Avoid concatenating strings in buildFragment
Michał Gołębiowski-Owczarek [Wed, 10 Jun 2020 14:13:22 +0000 (16:13 +0200)]
Manipulation: Avoid concatenating strings in buildFragment

Concatenating HTML strings in buildFragment is a possible security risk as it
creates an opportunity of escaping the concatenated wrapper. It also makes it
impossible to support secure HTML wrappers like
[trusted types](https://web.dev/trusted-types/). It's safer to create wrapper
elements using `document.createElement` & `appendChild`.

The previous way was needed in jQuery <4 because IE <10 doesn't accept table
parts set via `innerHTML`, even if the element which contents are set is
a proper table element, e.g.:
```js
tr.innerHTML = "<td></td>";
```
The whole structure needs to be passed in one HTML string. jQuery 4 drops
support for IE <11 so this is no longer an issue; in older version we'd have
to duplicate the code paths.

IE <10 needed to have `<option>` elements wrapped in
`<select multiple="multiple">` but we no longer need that on master which
makes the `document.createElement` way shorter as we don't have to call
`setAttribute`.

All these improvements, apart from making logic more secure, decrease the
gzipped size by 58 bytes.

Closes gh-4724
Ref gh-4409
Ref angular/angular.js#17028

Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
4 years agoDocs: Update Frequently Reported Issues in the GitHub issue template
Michał Gołębiowski-Owczarek [Mon, 8 Jun 2020 18:25:11 +0000 (20:25 +0200)]
Docs: Update Frequently Reported Issues in the GitHub issue template

The issue about selectors with '#' being broken is old and no longer
frequently reported so this commit removes it from the list. On the other
hand, we're now getting lots of reports about the security fix in jQuery 3.5.0
that was also a breaking change: gh-4642. This one is now mentioned in the
list.

Closes gh-4728
Ref gh-4642

4 years agoBuild:Event: Make sure all source modules' exports are used (#4648)
Michał Gołębiowski-Owczarek [Tue, 2 Jun 2020 11:45:08 +0000 (13:45 +0200)]
Build:Event: Make sure all source modules' exports are used (#4648)

To achieve that, use `eslint-plugin-import`'s `no-unused-modules` rule.

Also, explicitly import `event/trigger.js` from `jquery.js`; so far it was
only imported from ajax.js, making it mistakenly skipped in the
`custom:slim,-deprecated` build.

4 years agoDeprecated: Remove jQuery.trim
Michał Gołębiowski-Owczarek [Mon, 18 May 2020 21:20:38 +0000 (23:20 +0200)]
Deprecated: Remove jQuery.trim

The API has been deprecated in 3.5.0 so it can be removed in 4.0.0.

Ref gh-4461
Closes gh-4695

4 years agoRelease: Remove an unused chalk dependency
Michał Gołębiowski-Owczarek [Mon, 18 May 2020 20:45:04 +0000 (22:45 +0200)]
Release: Remove an unused chalk dependency

Chalk was used for a Sizzle version check that's no longer there on `master`.

Closes gh-4712

4 years agoBuild: Update eslint-config-jquery, fix linting violations
Michał Gołębiowski-Owczarek [Mon, 18 May 2020 20:25:49 +0000 (22:25 +0200)]
Build: Update eslint-config-jquery, fix linting violations

Closes gh-4696
Ref jquery/eslint-config-jquery#15
Ref jquery/eslint-config-jquery#16

4 years agoTests: Remove remaining obsolete jQuery.cache references
Michał Gołębiowski-Owczarek [Mon, 18 May 2020 16:43:01 +0000 (18:43 +0200)]
Tests: Remove remaining obsolete jQuery.cache references

PR gh-4586 removed some of those but not all.

Closes gh-4715
Ref gh-4586

4 years agoDocs: Change JS Foundation mentions to OpenJS Foundation
Michał Gołębiowski-Owczarek [Mon, 18 May 2020 16:41:32 +0000 (18:41 +0200)]
Docs: Change JS Foundation mentions to OpenJS Foundation

Closes gh-4711

4 years agoDocs: add SECURITY.md, show security email address
Timmy Willison [Tue, 12 May 2020 18:33:45 +0000 (14:33 -0400)]
Docs: add SECURITY.md, show security email address

4 years agoBuild: Followups after introducing ES modules compiled via Rollup
Michał Gołębiowski-Owczarek [Tue, 5 May 2020 12:30:14 +0000 (14:30 +0200)]
Build: Followups after introducing ES modules compiled via Rollup

This commit cleans up a few comments & configurations that are out of date
after the migration to ES modules backed by a Rollup-based compilation.

Also, de-indent AMD modules. This will preserve a more similar
structure to the one on 3.x-stable where the body of the main `define`
wrapper is not indented.

Closes gh-4705

4 years agoCSS: Include `show`, `hide` & `toggle` methods in the jQuery slim build
Michał Gołębiowski-Owczarek [Tue, 5 May 2020 12:16:41 +0000 (14:16 +0200)]
CSS: Include `show`, `hide` & `toggle` methods in the jQuery slim build

The `show()`, `hide()` & `toggle()` methods were included in the 3.x jQuery
slim build. The jQuery master build accidentally started to exclude them as
they were only imported in the effects module and the new Rollup-based build
system follows the module dependency graph when excluding modules.

To resolve the issue, import the `css/showHide.js` file directly in the main
`jquery.js` file.

Closes gh-4704
Ref jquery/jquery-migrate#346

4 years agoBuild: Correct code indentations based on jQuery Style Guide
Wonseop Kim [Tue, 5 May 2020 08:49:27 +0000 (17:49 +0900)]
Build: Correct code indentations based on jQuery Style Guide

1. Correct code indentations based on jQuery Style Guide
   (contribute.jquery.org/style-guide/js/#spacing).
2. Add rules to "src/.eslintrc.json" to enable "enforcing consistent
   indentation", with minimal changes to the current code.

Closes gh-4672

4 years agoTests: Workaround failures in recent XSS tests in iOS 8 - 12
Michał Gołębiowski-Owczarek [Thu, 30 Apr 2020 19:25:29 +0000 (21:25 +0200)]
Tests: Workaround failures in recent XSS tests in iOS 8 - 12

iOS 8-12 parses `<noembed>` tags differently, executing this code. This is no
different to native behavior on that OS, though, so just accept it.

Ref gh-4685
Closes gh-4694

4 years agoDocs: Fix typos
Pierre Grimaud [Wed, 29 Apr 2020 19:18:23 +0000 (21:18 +0200)]
Docs: Fix typos

Closes gh-4686

4 years agoTests: Add tests for recently fixed manipulation XSS issues
Michał Gołębiowski-Owczarek [Wed, 29 Apr 2020 14:39:04 +0000 (16:39 +0200)]
Tests: Add tests for recently fixed manipulation XSS issues

Closes gh-4685
Ref gh-4642
Ref gh-4647

4 years agoBuild: Reduce the slim build header comment & jQuery.fn.jquery
Michał Gołębiowski-Owczarek [Mon, 27 Apr 2020 20:23:59 +0000 (22:23 +0200)]
Build: Reduce the slim build header comment & jQuery.fn.jquery

So far, the slim build was expanded to its full exclusion list, generating the
following `jQuery.fn.jquery`:
```
v4.0.0-pre -ajax,-ajax/jsonp,-ajax/load,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-deprecated/ajax-event-alias,-callbacks,-deferred,-deferred/exceptionHook,-effects,-effects/Tween,-effects/animatedSelector,-queue,-queue/delay,-core/ready
```

This commit changes it to just `v4.0.0-pre slim`. Only the pure slim build is
treated this way, any modification to it goes through the old expansion; e.g.
for `custom:slim,-deprecated` we get the following `jQuery.fn.jquery`:
```
v4.0.0-pre -deprecated,-deprecated/ajax-event-alias,-deprecated/event,-ajax,-ajax/jsonp,-ajax/load,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-callbacks,-deferred,-deferred/exceptionHook,-effects,-effects/Tween,-effects/animatedSelector,-queue,-queue/delay,-core/ready
```

Since the version string is also put in the jQuery header comment, it also got
smaller.

Also, the logic to skip including the commit hash in the header comment - when
provided through the COMMIT environment variable which we do in Jenkins - in
minified builds headers has been applied to builds with exclusions as well.

Closes gh-4649

4 years agoTests: Use only one focusin/out handler per matching window & document
Michał Gołębiowski-Owczarek [Mon, 27 Apr 2020 19:37:06 +0000 (21:37 +0200)]
Tests: Use only one focusin/out handler per matching window & document

Backport tests from a jQuery 3.x fix that's not needed on `master`.

Also, fix the "focusin from an iframe" test to actually verify the behavior
from commit 1cecf64e5aa415367a7dae0b55c2dd17b591442d - the commit that
introduced the regression - to make sure we don't regress on either front.

The main part of the modified test was checking that focusin handling in an
iframe works and that's still checked. The test was also checking that it
doesn't propagate to the parent document, though, and, apparently, in IE it
does. This one test is now blacklisted in IE.

(cherry picked from 9e15d6b469556eccfa607c5ecf53b20c84529125)
(cherry picked from 1a4f10ddc37c34c6dc3a451ee451b5c6cf367399)

Ref gh-4652
Ref gh-4656
Closes gh-4657

4 years agoBuild: Move ESLint max-len disable-directive to dist/.eslintrc.json
Ed S [Mon, 27 Apr 2020 19:29:13 +0000 (20:29 +0100)]
Build: Move ESLint max-len disable-directive to dist/.eslintrc.json

This disable-directive only applies to the built version, so put
it in /dist. This avoids a warning about an unused directive in the
source version.

Closes gh-4676

4 years agoTests: Fix flakiness in the "jQuery.ajax() - JSONP - Same Domain" test
Michał Gołębiowski-Owczarek [Mon, 27 Apr 2020 18:22:39 +0000 (20:22 +0200)]
Tests: Fix flakiness in the "jQuery.ajax() - JSONP - Same Domain" test

The "jQuery.ajax() - JSONP - Same Domain" test is firing a request with
a duplicate "callback" parameter, something like (simplified):
```
mock.php?action=jsonp&callback=jQuery_1&callback=jQuery_2
```

There was a difference in how the PHP & Node.js implementations of the jsonp
action in the mock server handled situations like that. The PHP implementation
was using the latest parameter while the Node.js one was turning it into an
array but the code didn't handle this situation. Because of how JavaScript
stringifies arrays, while the PHP implementation injected the following code:
```js
jQuery_2(payload)
```
the Node.js one was injecting the following one:
```js
jQuery_1,jQuery_2(payload)
```
This is a comma expression in JavaScript; it so turned out that in the majority
of cases both callbacks were identical so it was more like:
```js
jQuery_1,jQuery_1(payload)
```
which evaluates to `jQuery_1(payload)` when `jQuery_1` is defined, making the
test go as expected. In many cases, though, especially on Travis, the callbacks
were different, triggering an `Uncaught ReferenceError` error & requiring
frequent manual re-runs of Travis builds.

This commit fixes the logic in the mock Node.js server, adding special handling
for arrays.

Closes gh-4687

4 years agoDocs: Update the link to the jsdom repository
Michał Gołębiowski-Owczarek [Sat, 25 Apr 2020 18:47:25 +0000 (20:47 +0200)]
Docs: Update the link to the jsdom repository

Closes gh-4684

4 years agoBuild: Test on Node.js 14, stop testing on Node.js 8 & 13
Michał Gołębiowski-Owczarek [Thu, 23 Apr 2020 11:24:35 +0000 (13:24 +0200)]
Build: Test on Node.js 14, stop testing on Node.js 8 & 13

Closes gh-4678

4 years agoBuild: Enable reportUnusedDisableDirectives in ESLint
Ed S [Mon, 20 Apr 2020 17:01:20 +0000 (18:01 +0100)]
Build: Enable reportUnusedDisableDirectives in ESLint

This forbids unnecessary `eslint-disable` comments.

Ref gh-4095
Closes gh-4520

4 years agoDocs: Use https for hyperlinks in README
Jonathan [Fri, 17 Apr 2020 09:46:49 +0000 (11:46 +0200)]
Docs: Use https for hyperlinks in README

Closes gh-4673

4 years agoAjax: Overwrite s.contentType with content-type header value, if any
Christian Wenz [Mon, 6 Apr 2020 19:15:55 +0000 (21:15 +0200)]
Ajax: Overwrite s.contentType with content-type header value, if any

This fixes the issue of "%20" in POST data being replaced with "+"
even for requests with content-type different from
"application/x-www-form-urlencoded", e.g. for "application/json".

Fixes gh-4119
Closes gh-4650

Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
Co-authored-by: Michał Gołębiowski-Owczarek <m.goleb@gmail.com>
4 years agoManipulation: Make jQuery.htmlPrefilter an identity function
Michał Gołębiowski-Owczarek [Mon, 16 Mar 2020 20:49:29 +0000 (21:49 +0100)]
Manipulation: Make jQuery.htmlPrefilter an identity function

Closes gh-4642

4 years agoBuild: Resolve Travis config warnings
Michał Gołębiowski-Owczarek [Fri, 13 Mar 2020 16:16:07 +0000 (17:16 +0100)]
Build: Resolve Travis config warnings

Travis reports warnings in our config:
* root: deprecated key sudo (The key `sudo` has no effect anymore.)
* root: missing os, using the default linux
* root: key matrix is an alias for jobs, using jobs

They are all now resolved.

Closes gh-4636

4 years agoData:Event:Manipulation: Prevent collisions with Object.prototype
Michał Gołębiowski-Owczarek [Mon, 2 Mar 2020 22:02:42 +0000 (23:02 +0100)]
Data:Event:Manipulation: Prevent collisions with Object.prototype

Make sure events & data keys matching Object.prototype properties work.
A separate fix for such events on cloned elements was added as well.

Fixes gh-3256
Closes gh-4603

4 years agoRelease: Use an in-repository dist README fixture
Michał Gołębiowski-Owczarek [Mon, 2 Mar 2020 21:42:38 +0000 (22:42 +0100)]
Release: Use an in-repository dist README fixture

Use a dist README fixture kept in the jQuery repository instead of modifying
an existing one. This makes the jQuery repository the single source of truth
when it comes to jQuery releases and it makes it easier to make changes to
README without worrying how it will affect older jQuery lines.

The commit also ES6ifies build/release.js & build/release/dist.js

Closes gh-4614

4 years agoBuild: Enable ESLint one-var rule for var declarations in browser code
Michał Gołębiowski-Owczarek [Mon, 2 Mar 2020 21:25:35 +0000 (22:25 +0100)]
Build: Enable ESLint one-var rule for var declarations in browser code

Node.js code is written more & more commonly in ES6+ so it doesn't make sense
to enable it there. There are many violations in test code so it's disabled
there as well.

Closes gh-4615

4 years agoTests: Pass a number of necessary done() calls to assert.async()
Michał Gołębiowski-Owczarek [Mon, 2 Mar 2020 21:15:06 +0000 (22:15 +0100)]
Tests: Pass a number of necessary done() calls to assert.async()

It is no longer needed to create `done` wrappers in tests that require
multiple async operations to complete.

Closes gh-4633

4 years agoBuild: Add Christian Oliff to .mailmap & AUTHORS.txt
Michał Gołębiowski-Owczarek [Mon, 24 Feb 2020 18:10:32 +0000 (19:10 +0100)]
Build: Add Christian Oliff to .mailmap & AUTHORS.txt

Closes gh-4613

4 years agoCore: Fire iframe script in its context, add doc param in globalEval
Michał Gołębiowski-Owczarek [Mon, 10 Feb 2020 18:17:22 +0000 (19:17 +0100)]
Core: Fire iframe script in its context, add doc param in globalEval

1. Support passing custom document to jQuery.globalEval; the script will be
   invoked in the context of this document.
2. Fire external scripts appended to iframe contents in that iframe context;
   this was already supported & tested for inline scripts but not for external
   ones.

Fixes gh-4518
Closes gh-4601

4 years agoEvent: remove jQuery.event.global
Michał Gołębiowski-Owczarek [Mon, 10 Feb 2020 18:13:09 +0000 (19:13 +0100)]
Event: remove jQuery.event.global

jQuery.event.global has been write-only in the jQuery source for the past few
years; reading from it was removed in c2d6847de09a52496f78baebc04f317e11ece6d2
when fixing the trac-12989 bug.

Closes gh-4602

4 years agoDocs: Remove a mention of the event/alias.js module from README
Michał Gołębiowski-Owczarek [Mon, 27 Jan 2020 18:22:05 +0000 (19:22 +0100)]
Docs: Remove a mention of the event/alias.js module from README

The file contents now lie in deprecated/event.js so the README reference
is no longer correct.

Ref gh-4572
Closes gh-4599

4 years agoBuild: Lint the minified jQuery file as well - a Gruntfile fix
Michał Gołębiowski-Owczarek [Mon, 27 Jan 2020 18:21:23 +0000 (19:21 +0100)]
Build: Lint the minified jQuery file as well - a Gruntfile fix

While we have absolutely no style-related expectations to our minified file,
we do care that it's valid ES 5.1. This is now verified.

Fixes gh-3075
Ref gh-4594
Closes gh-4598

4 years agoAjax: Deprecate AJAX event aliases, inline event/alias into deprecated
Michał Gołębiowski-Owczarek [Tue, 21 Jan 2020 13:12:35 +0000 (14:12 +0100)]
Ajax: Deprecate AJAX event aliases, inline event/alias into deprecated

A new `src/deprecated` directory makes it possible to exclude some deprecated
APIs from a custom build when their respective "parent" module is excluded
without keeping that module outside of the `src/deprecated` directory or
the `src/deprecated.js` file.

Closes gh-4572