]> source.dussan.org Git - jquery.git/log
jquery.git
12 months agoCore: Simplify code post browser support reduction
Michał Gołębiowski-Owczarek [Tue, 19 Sep 2023 22:54:40 +0000 (00:54 +0200)]
Core: Simplify code post browser support reduction

Summary of the changes:
* Core: Simplify code post browser support reduction
* Tests: Remove legacy jQuery.cache & oldIE leftovers
* Tests: Reformat JavaScript in delegatetest.html
* Docs: "jQuery Foundation Projects" -> "jQuery Projects"
* Tests: Drop an unused localfile.html file (modern browsers don't support
  the `file:` protocol this way, there's no point in keeping the file around)
* Effects: Remove a redundant `!fn` check (`fn || !fn && easing` is equivalent
  to `fn || easing`; simplify the code)
* CSS: Explain the fallback to direct object access in curCSS better
* Tests: Deduplicate `jQuery.parseHTML` test titles
* Dimensions: Add a test for fractional values
* Tests: Fix a buggy WebKit regex

Closes gh-5296

12 months agoCore: Move the factory to separate exports
Michał Gołębiowski-Owczarek [Tue, 19 Sep 2023 16:58:24 +0000 (18:58 +0200)]
Core: Move the factory to separate exports

Since versions 1.11.0/2.1.0, jQuery has used a module wrapper with one strange
addition - in CommonJS environments, if a global `window` with a `document` was
not present, jQuery exported a factory accepting a `window` implementation and
returning jQuery.

This approach created a number of problems:
1. Properly typing jQuery would be a nightmare as the exported value depends on
   the environment. In practice, typing definitions ignored the factory case.
2. Since we now use named exports for the jQuery module version, it felt weird
   to have `jQuery` and `$` pointing to the factory instead of real jQuery.

Instead, for jQuery 4.0 we leverage the just added `exports` field in
`package.json` to expose completely separate factory entry points: one for the
full build, one for the slim one.

Exports definitions for `./factory` & `./factory-slim` are simpler than for `.`
and `./slim` - this is because it's a new entry point, we only expose a named
export and so there's no issue with just pointing Node.js to the CommonJS
version (we cannot use the module version for `import` from Node.js to avoid
double package hazard). The factory entry points are also not meant for the Web
browser which always has a proper `window` - and they'd be unfit for an
inclusion in a regular script tag anyway. Because of that, we also don't
generate minified versions of these entry points.

The factory files are not pushed to the CDN since they are mostly aimed
at Node.js.

Closes gh-5293

12 months agoBuild: Bump qs, socket.io-parser, socket.io & json5
dependabot[bot] [Mon, 18 Sep 2023 16:39:28 +0000 (16:39 +0000)]
Build: Bump qs, socket.io-parser, socket.io & json5

1: Bump json5 from 2.2.0 to 2.2.3

Bumps [json5](https://github.com/json5/json5) from 2.2.0 to 2.2.3.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](https://github.com/json5/json5/compare/v2.2.0...v2.2.3)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

2: Bump socket.io-parser and socket.io

Bumps [socket.io-parser](https://github.com/socketio/socket.io-parser)
and [socket.io](https://github.com/socketio/socket.io). These dependencies
needed to be updated together.

Updates `socket.io-parser` from 4.0.5 to 4.2.4
- [Release notes](https://github.com/socketio/socket.io-parser/releases)
- [Changelog](https://github.com/socketio/socket.io-parser/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io-parser/compare/4.0.5...4.2.4)

Updates `socket.io` from 4.5.1 to 4.7.2
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/4.5.1...4.7.2)

---
updated-dependencies:
- dependency-name: socket.io-parser
  dependency-type: indirect
- dependency-name: socket.io
  dependency-type: indirect
...

3: Bump qs from 6.5.2 to 6.5.3

Bumps [qs](https://github.com/ljharb/qs) from 6.5.2 to 6.5.3.
- [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ljharb/qs/compare/v6.5.2...v6.5.3)

---
updated-dependencies:
- dependency-name: qs
  dependency-type: indirect
...

Closes gh-5324
Closes gh-5325
Closes gh-5326

Signed-off-by: dependabot[bot] <support@github.com>
12 months agoBuild: migrate most grunt tasks off of grunt
Timmy Willison [Mon, 18 Sep 2023 16:39:00 +0000 (12:39 -0400)]
Build: migrate most grunt tasks off of grunt

Updated tasks include:

- lint
- npmcopy
- build, minify, and process for distribution.
- new custom build command using yargs
- compare size of minified/gzip built files
- pretest scripts, including qunit-fixture, babel transpilation, and npmcopy
- node smoke tests
- promises aplus tests
- new watch task using `rollup.watch` directly

Also:

- upgraded husky and added the new lint command
- updated lint config to use new "flat" config format. See https://eslint.org/docs/latest/use/configure/configuration-files-new
- Temporarily disabled one lint rule until flat config is supported by eslint-plugin-import. See https://github.com/import-js/eslint-plugin-import/issues/2556
- committed package-lock.json
- updated all test scripts to use the new build
- added an express test server that uses middleware-mockserver (this can be used to run tests without karma)
- build-all-variants is now build:all

Close gh-5318

13 months agoCore: Use named exports in `src/`
Michał Gołębiowski-Owczarek [Tue, 12 Sep 2023 00:27:19 +0000 (02:27 +0200)]
Core: Use named exports in `src/`

The `default` export is treated differently across tooling when transpiled
to CommonJS - tools differ on whether `module.exports` represents the full
module object or just its default export. Switch `src/` modules to named
exports for tooling consistency.

Fixes gh-5262
Closes gh-5292

13 months agoBuild: Bump actions/checkout, actions/setup-node & github/codeql-action
dependabot[bot] [Fri, 1 Sep 2023 00:37:59 +0000 (00:37 +0000)]
Build: Bump actions/checkout, actions/setup-node & github/codeql-action

1: Bump actions/checkout from 3.5.3 to 3.6.0

Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.3 to 3.6.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/c85c95e3d7251135ab7dc9ce3241c5835cc595a9...f43a0e5ff2bd294095638e18286ca9a3d1956744)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

2: Bump actions/setup-node from 3.6.0 to 3.8.1

Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3.6.0 to 3.8.1.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c...5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

3: Bump github/codeql-action from 2.20.1 to 2.21.5

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.20.1 to 2.21.5.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/f6e388ebf0efc915c6c5b165b019ee61a6746a38...00e563ead9f72a8461b24876bee2d0c2e8bd2ee8)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Closes gh-5311
Closes gh-5312
Closes gh-5313

Signed-off-by: dependabot[bot] <support@github.com>
13 months agoBuild: Update mailmap entry for Krinkle
Timo Tijhof [Fri, 25 Aug 2023 14:19:15 +0000 (15:19 +0100)]
Build: Update mailmap entry for Krinkle

Close gh-5309

14 months agoBuild: replace CRLF with LF during minify
Timmy Willison [Fri, 11 Aug 2023 01:13:24 +0000 (21:13 -0400)]
Build: replace CRLF with LF during minify

- SWC is not respecting the git setting and does not have
  an option to force LF. This fixes the build on Windows.

Close gh-5305

15 months agoBuild: Add `exports` to package.json, export slim & esm builds
Michał Gołębiowski-Owczarek [Mon, 10 Jul 2023 17:14:08 +0000 (19:14 +0200)]
Build: Add `exports` to package.json, export slim & esm builds

Summary of the changes:
* define the `exports` field in `package.json`; `jQuery` & `$` are also
  exported as named exports in ESM builds now
* declare `"type": "module"` globally except for the `build` folder
* add the `--esm` option to `grunt custom`, generating jQuery as an ECMAScript
  module into the `dist-module` folder
* expand `node_smoke_tests` to test the slim & ESM builds and their various
  combinations; also, test both jQuery loaded via a path to the file as well
  as from module specifiers that should be parsed via the `exports` feature
* add details about ESM usage to the release package README
* run `compare_size` on all built minified files; don't run it anymore on
  unminified files where they don't provide lots of value
* remove the remove_map_comment task; SWC doesn't insert the
`//# sourceMappingURL=` pragma by default so there's nothing to strip

Fixes gh-4592
Closes gh-5255

15 months agoCSS: Make the reliableTrDimensions support test work with Bootstrap CSS
Michał Gołębiowski-Owczarek [Mon, 10 Jul 2023 16:33:05 +0000 (18:33 +0200)]
CSS: Make the reliableTrDimensions support test work with Bootstrap CSS

Bootstrap 5 includes the following CSS on the page:

```css
*,
*::before,
*::after {
  box-sizing: border-box;
}
```

That threw our `reliableTrDimensions` support test off. This change fixes the
support test and adds a unit test ensuring support test values on a page
including Bootstrap 5 CSS are the same as on a page without it.

Fixes gh-5270
Closes gh-5278
Ref gh-5279

15 months agoBuild: Switch form Terser to SWC for JS minification (#5286)
Michał Gołębiowski-Owczarek [Mon, 10 Jul 2023 16:23:07 +0000 (18:23 +0200)]
Build: Switch form Terser to SWC for JS minification (#5286)

Also, as part of this, fix the `file` & `sources` properties of the source map
file.

Fixes gh-5285
Closes gh-5286
Ref gh-5258

15 months agoBuild: Make sure `*.cjs` & `*.mjs` files use UNIX line endings as well
Michał Gołębiowski-Owczarek [Mon, 10 Jul 2023 16:19:52 +0000 (18:19 +0200)]
Build: Make sure `*.cjs` & `*.mjs` files use UNIX line endings as well

We've had this rule for `*.js` files so far but we now have two new JS
extensions.

Closes gh-5290

15 months agoBuild: switch preferred email for timmywil
Timmy Willison [Mon, 10 Jul 2023 14:59:12 +0000 (10:59 -0400)]
Build: switch preferred email for timmywil

Close gh-5288

15 months agoBuild: Bump github/codeql-action & actions/checkout
dependabot[bot] [Sat, 1 Jul 2023 00:28:46 +0000 (00:28 +0000)]
Build: Bump github/codeql-action & actions/checkout

1: Bump github/codeql-action from 2.3.6 to 2.20.1

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.3.6 to 2.20.1.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/83f0fe6c4988d98a455712a27f0255212bba9bd4...f6e388ebf0efc915c6c5b165b019ee61a6746a38)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

2: Build: Bump actions/checkout from 3.5.2 to 3.5.3

Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.2 to 3.5.3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/8e5e7e5ab8b370d6c329ec480221332ada57f0ab...c85c95e3d7251135ab7dc9ce3241c5835cc595a9)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Closes gh-5283
Closes gh-5284

15 months agoDocs: Fix typos found by codespell
Dimitri Papadopoulos Orfanos [Tue, 27 Jun 2023 22:29:29 +0000 (00:29 +0200)]
Docs: Fix typos found by codespell

Closes gh-5165

15 months agoBuild: Drop individual AMD modules
Michał Gołębiowski-Owczarek [Tue, 27 Jun 2023 16:23:58 +0000 (18:23 +0200)]
Build: Drop individual AMD modules

With this change, jQuery build no longer generates the `amd` directory with
AMD modules transpiled from source `src` ECMAScript Modules. To use individual
jQuery modules from source, ESM is now required.

Note that this DOES NOT affect the main `"jquery"` AMD module defined by built
jQuery files; those remain supported.

Closes gh-5276

15 months agoTests: Disable the ":lang respects escaped backslashes" test
Michał Gołębiowski-Owczarek [Tue, 27 Jun 2023 16:05:46 +0000 (18:05 +0200)]
Tests: Disable the ":lang respects escaped backslashes" test

Firefox 114+ no longer match on backslashes in `:lang()`, even when escaped.
It is an intentional change as `:lang()` parameters are supposed to be valid
BCP 47 strings. Therefore, we won't attempt to patch it.
We'll keep this test here until other browsers match the behavior.

Fixes gh-5271
Closes gh-5277
Ref https://bugzilla.mozilla.org/show_bug.cgi?id=1839747#c1
Ref https://github.com/w3c/csswg-drafts/issues/8720#issuecomment-1509242961

15 months agoDocs: remove stale gitter badge from readme
Timmy Willison [Fri, 23 Jun 2023 13:43:26 +0000 (09:43 -0400)]
Docs: remove stale gitter badge from readme

Close gh-5273

16 months agoBuild: Reference GitHub Actions by commit SHAs
Gabriela Gutierrez [Tue, 13 Jun 2023 21:22:07 +0000 (21:22 +0000)]
Build: Reference GitHub Actions by commit SHAs

The SHAs are verified to come from the original repositories and not forks.

For reference:

https://github.com/github/codeql-action/releases/tag/v2.3.6
https://github.com/github/codeql-action/commit/83f0fe6c4988d98a455712a27f0255212bba9bd4

https://github.com/actions/checkout/releases/tag/v3.5.2
https://github.com/actions/checkout/commit/8e5e7e5ab8b370d6c329ec480221332ada57f0ab

https://github.com/actions/cache/releases/tag/v3.3.1
https://github.com/actions/cache/commit/88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8

https://github.com/actions/setup-node/releases/tag/v3.6.0
https://github.com/actions/setup-node/commit/64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c

Fixes gh-5266
Closes gh-5269

Signed-off-by: Gabriela Gutierrez <gabigutierrez@google.com>
16 months agoCore: Fix regression in jQuery.text() on HTMLDocument objects
Timo Tijhof [Mon, 12 Jun 2023 21:12:15 +0000 (22:12 +0100)]
Core: Fix regression in jQuery.text() on HTMLDocument objects

Fixes gh-5264
Closes gh-5265

(cherry picked from commit 44c56f87a31fbc1f43ac575cfd06a0df12073352)

16 months agoSelector: Re-expose jQuery.find.{tokenize,select,compile,setDocument}
Michał Gołębiowski-Owczarek [Mon, 12 Jun 2023 20:58:55 +0000 (22:58 +0200)]
Selector: Re-expose jQuery.find.{tokenize,select,compile,setDocument}

`Sizzle.tokenize` is an internal Sizzle API, but exposed. As a result,
it has historically been available in jQuery via `jQuery.find.tokenize`.
That got dropped during Sizzle removal; this change restores the API.

Some other APIs so far only exposed on the `3.x` line are also added
back:
* `jQuery.find.select`
* `jQuery.find.compile`
* `jQuery.find.setDocument`

In addition to that, Sizzle tests have been backported for the following
APIs:
* `jQuery.find.matchesSelector`
* `jQuery.find.matches`
* `jQuery.find.compile`
* `jQuery.find.select`

A new test was also added for `jQuery.find.tokenize` - even Sizzle was
missing one.

Fixes gh-5259
Closes gh-5263
Ref gh-5260
Ref jquery/sizzle#242
Ref gh-5113
Ref gh-4395
Ref gh-4406

16 months agoBuild: Switch the minifier from UglifyJS to Terser
Michał Gołębiowski-Owczarek [Wed, 31 May 2023 16:59:35 +0000 (18:59 +0200)]
Build: Switch the minifier from UglifyJS to Terser

UglifyJS is ES5-only, while Terser supports newer ECMAScript versions. jQuery
is authored in ES5 but jQuery 4.x will also have an ESM build that cannot be
minified using UglifyJS directly.

We could strip the `export` statement, minify via UglifyJS and re-add one but
that increases complexity & may not fully play nice with source maps.

On the other hand, switching to Terser increases the minfied size by just 324
bytes and the minified gzipped one by just 70 bytes. Such differences largely
disappear among bigger size gains from the `3.x-stable` line - around 2.7 KB
minified gzipped as of now.

Closes gh-5258

16 months agoDocs: Remove the "Grunt build" section from the PR template
Michał Gołębiowski-Owczarek [Wed, 31 May 2023 16:57:13 +0000 (18:57 +0200)]
Docs: Remove the "Grunt build" section from the PR template

Now that unit tests are run on GitHub Actions in all three major
engines and for multiple custom jQuery builds, the request for PR
authors to run unit tests locally and confirm they pass is needless
overhead; let's drop the checkbox.

Closes gh-5261

16 months agoBuild: Make the `eslint:dev` task not lint the `dist/` folder
Michał Gołębiowski-Owczarek [Wed, 31 May 2023 16:55:29 +0000 (18:55 +0200)]
Build: Make the `eslint:dev` task not lint the `dist/` folder

There was a mistake in paths logic that made the `dist/` folder linted
even in the `eslint:dev` task which is run before the build. Fix that by
explicitly ignoring the `dist/` folder at the end of the file list.

Closes gh-5257

16 months agoDeprecated: Define `.hover()` using non-deprecated methods
Michał Gołębiowski-Owczarek [Mon, 22 May 2023 16:23:19 +0000 (18:23 +0200)]
Deprecated: Define `.hover()` using non-deprecated methods

Make the deprecated `.hover()` method not rely on other deprecated
methods: `.mouseenter()` & `.mouseleave()`. Use `.on()` instead.

Closes gh-5251

16 months agoBuild: Test on Node.js 20, stop testing on Node.js 14 & 19
Michał Gołębiowski-Owczarek [Mon, 22 May 2023 14:21:35 +0000 (16:21 +0200)]
Build: Test on Node.js 20, stop testing on Node.js 14 & 19

Closes gh-5250

18 months agoTests: Indicate Chrome 112 & Safari 16.4 pass the cssHas support test
Michał Gołębiowski-Owczarek [Tue, 4 Apr 2023 22:25:20 +0000 (00:25 +0200)]
Tests: Indicate Chrome 112 & Safari 16.4 pass the cssHas support test

Chrome 112 & Safari 16.4 introduce two changes:
* `:has()` is non-forgiving
* `CSS.supports( "selector(...)" )` parses everything in a non-forgiving way

We no longer care about the latter but the former means the `cssHas` support
test now passes.

Closes gh-5225

18 months agoCSS: Make `offsetHeight( true )`, etc. include negative margins
Michał Gołębiowski-Owczarek [Tue, 4 Apr 2023 14:00:55 +0000 (16:00 +0200)]
CSS: Make `offsetHeight( true )`, etc. include negative margins

This regressed in gh-3656 as the added logic to include scroll gutters
in `.innerWidth()` / `.innerHeight()` didn't take negative margins into
account. This broke handling of negative margins in
`.offsetHeight( true )` and `.offsetWidth( true )`. To fix it, calculate
margin delta separately and only add it after the scroll gutter
adjustment logic.

Fixes gh-3982
Closes gh-5234
Ref gh-3656

18 months agoEvent: Avoid collisions between jQuery.event.special & Object.prototype
Michał Gołębiowski-Owczarek [Mon, 3 Apr 2023 16:40:24 +0000 (18:40 +0200)]
Event: Avoid collisions between jQuery.event.special & Object.prototype

This is a follow-up to similar changes to data & event storages from
gh-4603.

Closes gh-5235
Ref gh-4603

18 months agoEvent: Simplify the check for saved data in leverageNative
Michał Gołębiowski-Owczarek [Mon, 3 Apr 2023 16:21:15 +0000 (18:21 +0200)]
Event: Simplify the check for saved data in leverageNative

Previously, when `leverageNative` handled async events, there was
a case where an empty placeholder object was set as a result.
Covering both such an object and `false` required a `length` check.
However, this is not necessary since gh-5223 and the check was
already simplified in other places; this one was missed.

Closes gh-5236
Ref gh-5223

18 months agoEvent: Make trigger(focus/blur/click) work with native handlers
Michał Gołębiowski-Owczarek [Mon, 27 Mar 2023 19:47:01 +0000 (21:47 +0200)]
Event: Make trigger(focus/blur/click) work with native handlers

In `leverageNative`, instead of calling `event.stopImmediatePropagation()`
which would abort both native & jQuery handlers, set the wrapper's
`isImmediatePropagationStopped` property to a function returning `true`.
Since for each element + type pair jQuery attaches only one native handler,
there is also only one wrapper jQuery event so this achieves the goal:
on the target element jQuery handlers don't fire but native ones do.

Unfortunately, this workaround doesn't work for handlers on ancestors
- since the native event is re-wrapped by a jQuery one on each level of
the propagation, the only way to stop it for jQuery was to stop it for
everyone via native `stopPropagation()`. This is not a problem for
`focus`/`blur` which don't bubble, but it does also stop `click` on
checkboxes and radios. We accept this limitation.

Fixes gh-5015
Closes gh-5228

18 months agoEvent: Simulate focus/blur in IE via focusin/focusout
Michał Gołębiowski-Owczarek [Mon, 27 Mar 2023 19:22:38 +0000 (21:22 +0200)]
Event: Simulate focus/blur in IE via focusin/focusout

In IE (all versions), `focus` & `blur` handlers are fired asynchronously
but `focusin` & `focusout` are run synchronously. In other browsers, all
those handlers are fired synchronously. Asynchronous behavior of these
handlers in IE caused issues for IE (gh-4856, gh-4859).

We now simulate `focus` via `focusin` & `blur` via `focusout` in IE to avoid
these issues. This also let us simplify some tests.

This commit also simplifies `leverageNative` - with IE now using `focusin`
to simulate `focus` and `focusout` to simulate `blur`, we don't have to deal
with async events in `leverageNative`. This also fixes broken `focus` triggers
after first triggering it on a hidden element - previously, `leverageNative`
assumed that the native `focus` handler not firing after calling the native
`focus` method meant it would be handled later, asynchronously, which
was not the case (gh-4950).

Fixes gh-4856
Fixes gh-4859
Fixes gh-4950
Closes gh-5223

Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
18 months agoAjax: Don't treat array data as binary
Michał Gołębiowski-Owczarek [Mon, 20 Mar 2023 23:36:00 +0000 (00:36 +0100)]
Ajax: Don't treat array data as binary

PR gh-5197 started treating all non-string non-plain-object
`data` values as binary. However, `jQuery.ajax` also supports
arrays as values of `data`. This change makes regular arrays
no longer be considered binary data.

Surprisingly, we had no tests for array `data` values; otherwise,
we'd detect the issue earlier. This change also adds
a few such missing tests.

Closes gh-5203
Ref gh-5197

18 months agoBuild: Only install Playwright dependencies when needed
Michał Gołębiowski-Owczarek [Mon, 20 Mar 2023 16:13:31 +0000 (17:13 +0100)]
Build: Only install Playwright dependencies when needed

PR gh-5190 added support for running tests on Playwright WebKit
in CI. For efficiency reasons, Playwright dependencies are only
installed for the `test:browser` npm script. However, that same
script is also used for Firefox ESR testing.

This change makes Playwright dependencies installed only for cases
where `WebKitHeadless` exists on the list of tested browsers.

Closes gh-5204
Ref gh-5190

18 months agoAjax: Allow `processData: true` even for binary data
Michał Gołębiowski-Owczarek [Mon, 20 Mar 2023 16:08:51 +0000 (17:08 +0100)]
Ajax: Allow `processData: true` even for binary data

The way gh-5197 implemented binary data handling, `processData`
was being explicitly set to `false`. This is expected but it made
it impossible to override it to `true`. The new logic will only
set `processData` to `false` if it wasn't explicitly passed
in original options.

Closes gh-5205
Ref gh-5197

19 months agoTests: Test AJAX deprecated event aliases properly
Michał Gołębiowski-Owczarek [Wed, 15 Mar 2023 10:44:08 +0000 (11:44 +0100)]
Tests: Test AJAX deprecated event aliases properly

PR gh-5046 erroneously changed AJAX deprecated event alias
usage in deprecated tests to `.on()` calls. This change
reverses this mistake.

Closes gh-5195
Ref gh-5046

19 months agoDeferred: Rename `getStackHook` to `getErrorHook`
Michał Gołębiowski-Owczarek [Tue, 14 Mar 2023 21:32:45 +0000 (22:32 +0100)]
Deferred: Rename `getStackHook` to `getErrorHook`

Rename `jQuery.Deferred.getStackHook` to `jQuery.Deferred.getErrorHook`
to indicate passing an error instance is usually a better choice - it
works with source maps while a raw stack generally does not.

In jQuery `3.7.0`, we'll keep both names, marking the old one as
deprecated. In jQuery `4.0.0` we'll just keep the new one. This
change implements the `4.0.0` version; PR gh-5212 implements
the `3.7.0` one.

Fixes gh-5201
Closes gh-5211
Ref gh-5212

19 months agoRelease: add support for md5 sums in windows
Timmy Willison [Thu, 9 Mar 2023 20:19:07 +0000 (15:19 -0500)]
Release: add support for md5 sums in windows

Close gh-5219

20 months agoSelector: Stop relying on CSS.supports( "selector(...)" )
Michał Gołębiowski-Owczarek [Tue, 14 Feb 2023 09:11:40 +0000 (10:11 +0100)]
Selector: Stop relying on CSS.supports( "selector(...)" )

`CSS.supports( "selector(...)" )` has different semantics than selectors passed
to `querySelectorAll`. Apart from the fact that the former returns `false` for
unrecognized selectors and the latter throws, `qSA` is more forgiving and
accepts some invalid selectors, auto-correcting them where needed - for
example, mismatched brackers are auto-closed. This behavior difference is
breaking for many users.

To add to that, a recent CSSWG resolution made `:is()` & `:where()` the only
pseudos with forgiving parsing; browsers are in the process of making `:has()`
parsing unforgiving.

Taking all that into account, we go back to our previous try-catch approach
without relying on `CSS.supports( "selector(...)" )`. The only difference
is we detect forgiving parsing in `:has()` and mark the selector as buggy.

The PR also updates `playwright-webkit` so that we test against a version
of WebKit that already has non-forgiving `:has()`.

Fixes gh-5194
Closes gh-5206
Ref gh-5098
Ref gh-5107
Ref w3c/csswg-drafts#7676

Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
20 months agoSelector: Backport jQuery selection context logic to selector-native
Michał Gołębiowski-Owczarek [Mon, 13 Feb 2023 17:34:41 +0000 (18:34 +0100)]
Selector: Backport jQuery selection context logic to selector-native

This makes:
```js
$div.find("div > *")
```
no longer matching children of `$div`.

Also, leading combinators now work, e.g.:
```js
$div.find( "> *" );
```
returns children of `$div`.

As a result of that, a number of tests are no longer skipped in the
`selector-native` mode.

Also, rename `rcombinators` to `rleadingCombinator`.

Fixes gh-5185
Closes gh-5186
Ref gh-5085

20 months agoBuild: Bump actions/setup-node from 3.5.1 to 3.6.0
dependabot[bot] [Thu, 2 Feb 2023 00:43:00 +0000 (01:43 +0100)]
Build: Bump actions/setup-node from 3.5.1 to 3.6.0

Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3.5.1 to 3.6.0.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v3.5.1...v3.6.0)

Closes gh-5200

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
20 months agoAjax: Support binary data (including FormData)
Michał Gołębiowski-Owczarek [Wed, 1 Feb 2023 12:48:35 +0000 (13:48 +0100)]
Ajax: Support binary data (including FormData)

Two changes have been applied:
* prefilters are now applied before data is converted to a string;
  this allows prefilters to disable such a conversion
* a prefilter for binary data is added; it disables data conversion
  for non-string non-plain-object `data`; for `FormData` bodies, it
  removes manually-set `Content-Type` header - this is required
  as browsers need to append their own boundary to the header

Ref gh-4150
Closes gh-5197

20 months agoDeferred: Respect source maps in jQuery.Deferred.exceptionHook
Michał Gołębiowski-Owczarek [Wed, 1 Feb 2023 12:46:44 +0000 (13:46 +0100)]
Deferred: Respect source maps in jQuery.Deferred.exceptionHook

So far, `jQuery.Deferred.exceptionHook` used to log error message and stack
separately. However, that breaks browser applying source maps against the stack
trace - most browsers require logging an error instance. This change makes us
do exactly that.

One drawback of the change is that in IE 11 previously stack was printed
directly and now just the error summary; to get to the actual stack
trace, three clicks are required. This seems to be a low price to pay
for having source maps work in all the other browsers, though.

Safari with the new change requires one click to get to the stack trace
which sounds manageable.

Fixes gh-3179
Closes gh-5192
Ref https://crbug.com/622227

20 months agoAjax: Support `headers` for script transport even when cross-domain
Michał Gołębiowski-Owczarek [Wed, 1 Feb 2023 12:40:55 +0000 (13:40 +0100)]
Ajax: Support `headers` for script transport even when cross-domain

The AJAX script transport has two versions: XHR + `jQuery.globalEval` or
appending a script tag (note that `jQuery.globalEval` also appends a
script tag now, but inline). The former cannot support the `headers`
option which has so far not been taken into account.

For jQuery 3.x, the main consequence was the option not being respected
for cross-domain requests. Since in 4.x we use the latter way more
often, the option was being ignored in more cases.

The transport now checks whether the `headers` option is specified and
uses the XHR way unless `scriptAttrs` are specified as well.

Fixes gh-5142
Closes gh-5193

20 months agoBuild: Run GitHub Action browser tests on Playwright WebKit
Michał Gołębiowski-Owczarek [Mon, 23 Jan 2023 22:49:44 +0000 (23:49 +0100)]
Build: Run GitHub Action browser tests on Playwright WebKit

So far, we've been running browser tests on GitHub Actions in Chrome
and Firefox. Regular Safari is not available in GitHub Actions but
Playwright WebKit comes close to a dev version of Safari.

With this change, our GitHub CI & local test runs will invoke tests on
all actively developed browser engines on all PRs.

Also, our GitHub Actions browser tests are now running on Node.js 18.

Detection of the Playwright WebKit browser in support unit tests is done
by checking if the `test_browser` query parameter is set to `"Playwright"`;
this is a `karma-webkit-launcher` feature. Detecting that browser via
user agent as we normally do is hard as the UA on Linux is very similar
to a real Safari one but it actually uses a newer version of the engine.

In addition, we now allow to pass custom browsers when one needs it;
e.g., to run the tests in all three engines on Linux/macOS, run:
```
grunt && BROWSERS=ChromeHeadless,FirefoxHeadless,WebkitHeadless grunt karma:main
```

Closes gh-5190

20 months agoBuild: Migrate middleware-mockserver to modern JS
Michał Gołębiowski-Owczarek [Mon, 23 Jan 2023 22:20:08 +0000 (23:20 +0100)]
Build: Migrate middleware-mockserver to modern JS

The `test/middleware-mockserver.js` file used to have the same ESLint
settings applied as other test files that are directly run in tested
browsers. Now it shares settings of other Node.js files.

The file is now also written using modern JS, leveraging ES2018.

Closes gh-5196

21 months agoBuild: remove stale Insight package from custom builds
Timmy Willison [Tue, 20 Dec 2022 20:57:49 +0000 (20:57 +0000)]
Build: remove stale Insight package from custom builds

Close gh-5182

21 months agoSelector: Make selector lists work with `qSA` again
Michał Gołębiowski-Owczarek [Mon, 19 Dec 2022 17:43:30 +0000 (18:43 +0100)]
Selector: Make selector lists work with `qSA` again

jQuery 3.6.2 started using `CSS.supports( "selector(SELECTOR)" )` before using
`querySelectorAll` on the selector. This was to solve gh-5098 - some selectors,
like `:has()`, now had their parameters parsed in a forgiving way, meaning
that `:has(:fakepseudo)` no longer throws but just returns 0 results, breaking
that jQuery mechanism.

A recent spec change made `CSS.supports( "selector(SELECTOR)" )` always use
non-forgiving parsing, allowing us to use this API for what we've used
`try-catch` before.

To solve the issue on the spec side for older jQuery versions, `:has()`
parameters are no longer using forgiving parsing in the latest spec update
but our new mechanism is more future-proof anyway.

However, the jQuery implementation has a bug - in
`CSS.supports( "selector(SELECTOR)" )`, `SELECTOR` needs to be
a `<complex-selector>` and not a `<complex-selector-list>`. Which means that
selector lists now skip `qSA` and go to the jQuery custom traversal:
```js
CSS.supports("selector(div:valid, span)"); // false
CSS.supports("selector(div:valid)"); // true
CSS.supports("selector(span)"); // true
```

To solve this, this commit wraps the selector list passed to
`CSS.supports( "selector(:is(SELECTOR))" )` with `:is`, making it a single
selector again.

See:
* https://w3c.github.io/csswg-drafts/css-conditional-4/#at-supports-ext
* https://w3c.github.io/csswg-drafts/selectors-4/#typedef-complex-selector
* https://w3c.github.io/csswg-drafts/selectors-4/#typedef-complex-selector-list

Fixes gh-5177
Closes gh-5178
Ref w3c/csswg-drafts#7280

22 months agoCore:Selector: Move jQuery.contains from the selector to the core module
Michał Gołębiowski-Owczarek [Mon, 12 Dec 2022 21:27:59 +0000 (22:27 +0100)]
Core:Selector: Move jQuery.contains from the selector to the core module

The `jQuery.contains` method is quite simple in jQuery 4+. On the other side,
it's a dependency of the core `isAttached` util which is not ideal; moving
it from the `selector` the `core` module resolves the issue.

Closes gh-5167

22 months agoBuild: Limit permissions for GitHub workflows
Alex [Thu, 1 Dec 2022 13:23:17 +0000 (15:23 +0200)]
Build: Limit permissions for GitHub workflows

Add explicit permissions section[^1] to workflows. This is a security
best practice because by default workflows run with extended set
of permissions[^2] (except from `on: pull_request` from external forks[^3].
By specifying any permission explicitly all others are set to none. By using
the principle of least privilege the damage a compromised workflow can do
(because of an injection[^4] or compromised third party tool or action) is
restricted. It is recommended to have most strict permissions on the top
level[^5] and grant write permissions on job level[^6] on a case by case
basis.

[^1]: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
[^2]: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
[^3]: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
[^4]: https://securitylab.github.com/research/github-actions-untrusted-input/
[^5]: https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions
[^6]: https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs

Closes gh-5119

22 months agoSelector: Implement the `uniqueSort` chainable method
Michał Gołębiowski-Owczarek [Mon, 28 Nov 2022 17:10:33 +0000 (18:10 +0100)]
Selector: Implement the `uniqueSort` chainable method

Some APIs, like `.prevAll()`, return elements in the reversed order, causing
confusing behavior when used with wrapping methods (see gh-5149 for more info)
 To provide an easy workaround, this commit implements a chainable `uniqueSort`
method on jQuery objects, an equivalent of `jQuery.uniqueSort`.

Fixes gh-5166
Closes gh-5168

22 months agoTests: Indicate Firefox 106+ passes the `cssSupportsSelector` test
Michał Gołębiowski-Owczarek [Thu, 24 Nov 2022 23:54:56 +0000 (00:54 +0100)]
Tests: Indicate Firefox 106+ passes the `cssSupportsSelector` test

Firefox 106 adjusted to the spec mandating that `CSS.supports("selector(...)")`
uses non-forgiving parsing which makes it pass the relevant support test.

Closes gh-5141

22 months agoSelector: Re-introduce selector-native.js
Michał Gołębiowski-Owczarek [Mon, 21 Nov 2022 22:23:39 +0000 (23:23 +0100)]
Selector: Re-introduce selector-native.js

Re-introduce the `selector-native` similar to the one on the `3.x-stable`
branch. One difference is since the `main` branch inlined Sizzle, some
selector utils can be shared between the main `selector` module and
`selector-native`.

The main `selector` module can be disabled in favor of `selector-native`
via:

    grunt custom:-selector

Other changes:
* Tests: Fix Safari detection - Chrome Headless has a different user
  agent than Safari and a browser check in selector tests didn't take
  that into account.
* Tests: Run selector-native tests in `npm test`
* Selector: Fix querying on document fragments

Ref gh-4395
Closes gh-5085

22 months agoBuild: Test on Node.js 18 & 19, stop testing on Node 12
Michał Gołębiowski-Owczarek [Thu, 17 Nov 2022 12:22:21 +0000 (13:22 +0100)]
Build: Test on Node.js 18 & 19, stop testing on Node 12

Closes gh-5160

23 months agoSelector:Manipulation: Fix DOM manip within template contents
Michał Gołębiowski-Owczarek [Mon, 14 Nov 2022 17:36:53 +0000 (18:36 +0100)]
Selector:Manipulation: Fix DOM manip within template contents

The `<template/>` element `contents` property is a document fragment that may
have a `null` `documentElement`. In Safari 16 this happens in more cases due
to recent spec changes - in particular, even if that document fragment is
explicitly adopted into an outer document. We're testing both of those cases
now.

The crash used to happen in `jQuery.contains`. As it turns out, we don't need
to query the supposed container `documentElement` if it has the
`Node.DOCUMENT_NODE` (9) `nodeType`; we can call `.contains()` directly on
the `document`. That avoids the crash.

Fixes gh-5147
Closes gh-5158

23 months agoBuild: Bump actions/setup-node from 3.5.0 to 3.5.1
dependabot[bot] [Tue, 1 Nov 2022 19:58:52 +0000 (20:58 +0100)]
Build: Bump actions/setup-node from 3.5.0 to 3.5.1

Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3.5.0 to 3.5.1.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v3.5.0...v3.5.1)

Closes gh-5153

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
23 months agoDocs: Remove stale badge from README
Timmy Willison [Mon, 24 Oct 2022 15:00:25 +0000 (11:00 -0400)]
Docs: Remove stale badge from README

Close gh-5148

23 months agoAjax: Support `null` as success functions in `jQuery.get`
Michał Gołębiowski-Owczarek [Mon, 17 Oct 2022 16:54:28 +0000 (18:54 +0200)]
Ajax: Support `null` as success functions in `jQuery.get`

According to the docs, one can use `null` as a success function in `jQuery.get`
of `jQuery.post` so the following:

```js
await jQuery.get( "https://httpbin.org/json", null, "text" )
```

should get the text result. However, this shortcut hasn't been working so far.

Fixes gh-4989
Closes gh-5139

2 years agoSelector: Drop support for legacy pseudos, test custom pseudos
Michał Gołębiowski-Owczarek [Tue, 11 Oct 2022 09:55:46 +0000 (11:55 +0200)]
Selector: Drop support for legacy pseudos, test custom pseudos

This backports custom pseudos tests from Sizzle; they were missed in original
test backports. Also, the support for legacy custom pseudos has been dropped.

The `jQuery.expr` test cleanup has been wrapped in `try-finally` for cleaner
test isolation in case anything goes wrong.

Closes gh-5137

2 years agoManipulation: Extract domManip to a separate file
Michał Gołębiowski-Owczarek [Mon, 10 Oct 2022 16:15:34 +0000 (18:15 +0200)]
Manipulation: Extract domManip to a separate file

We've already had `buildFragment` extracted to a separate file long ago.
`domManip` is quite a complex & crucial API and so far it has existed within
the `manipulation.js` module. Extracting it makes the module shorter and easier
to understand.

A few comments / messages in tests have also been updated to not suggest there's
a public `jQuery.domManip` API - it's been private since 3.0.0.

Closes gh-5138

2 years agoBuild: Update Grunt from 1.4.1 to 1.5.3
Michał Gołębiowski-Owczarek [Mon, 3 Oct 2022 21:06:37 +0000 (23:06 +0200)]
Build: Update Grunt from 1.4.1 to 1.5.3

This will resolve the following security issues:
* Path Traversal in Grunt: https://github.com/advisories/GHSA-j383-35pm-c5h4
* Race Condition in Grunt: https://github.com/advisories/GHSA-rm36-94g8-835r

Closes gh-5134

2 years agoDocs: Update the README of the published package
Michał Gołębiowski-Owczarek [Mon, 3 Oct 2022 20:55:49 +0000 (22:55 +0200)]
Docs: Update the README of the published package

The previous details were showing their age, e.g. mentions about browsers
not supporting ES2015. The story with ES modules is more complex as it's also
about loaders but to keep the README simple, let's just make it more up to date
with typical usage.

Closes gh-5108

2 years agoTests: Remove a workaround for a Firefox XML parsing issue
Michał Gołębiowski-Owczarek [Mon, 3 Oct 2022 20:53:39 +0000 (22:53 +0200)]
Tests: Remove a workaround for a Firefox XML parsing issue

Firefox 96-100 used to report the column number smaller by 2 than it should
in the `parsererror` element generated for invalid XML documents. Since that
version range is unsupported now and it includes no ESR versions, the workaround
can now be dropped.

Closes gh-5109
Ref gh-5018

2 years agoCSS: Return `undefined` for whitespace-only CSS variable values (#5120)
Michał Gołębiowski-Owczarek [Mon, 3 Oct 2022 16:10:42 +0000 (18:10 +0200)]
CSS: Return `undefined` for whitespace-only CSS variable values (#5120)

The spec requires that CSS variable values are trimmed. In browsers that do
this - mainly, Safari, but also Firefox if the value only has leading
whitespace - we currently return undefined; in other browsers, we return
an empty string as the logic to fall back to undefined happens before
trimming.

This commit adds another explicit callback to `undefined` to have it consistent
across browsers.

Also, more explicit comments about behaviors we need to work around in various
browsers have been added.

Closes gh-5120
Ref gh-5106

2 years agoBuild: Bump actions/setup-node from 3.4.1 to 3.5.0
dependabot[bot] [Mon, 3 Oct 2022 14:58:47 +0000 (16:58 +0200)]
Build: Bump actions/setup-node from 3.4.1 to 3.5.0

Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3.4.1 to 3.5.0.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v3.4.1...v3.5.0)

Closes gh-5133

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoCSS: Don’t trim whitespace of undefined custom property
Anders Kaseorg [Mon, 19 Sep 2022 21:08:12 +0000 (14:08 -0700)]
CSS: Don’t trim whitespace of undefined custom property

Fixes gh-5105
Closes gh-5106

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2 years agoSelector: Use jQuery `:has` if `CSS.supports(selector(...))` non-compliant
Michał Gołębiowski-Owczarek [Mon, 19 Sep 2022 18:56:02 +0000 (21:56 +0300)]
Selector: Use jQuery `:has` if `CSS.supports(selector(...))` non-compliant

jQuery has followed the following logic for selector handling for ages:
1. Modify the selector to adhere to scoping rules jQuery mandates.
2. Try `qSA` on the modified selector. If it succeeds, use the results.
3. If `qSA` threw an error, run the jQuery custom traversal instead.

It worked fine so far but now CSS has a concept of forgiving selector lists that
some selectors like `:is()` & `:has()` use. That means providing unrecognized
selectors as parameters to `:is()` & `:has()` no longer throws an error, it will
just return no results. That made browsers with native `:has()` support break
selectors using jQuery extensions inside, e.g. `:has(:contains("Item"))`.

Detecting support for selectors can also be done via:

```js
CSS.supports( "selector(SELECTOR_TO_BE_TESTED)" )
```
which returns a boolean. There was a recent spec change requiring this API to
always use non-forgiving parsing:
https://github.com/w3c/csswg-drafts/issues/7280#issuecomment-1143852187
However, no browsers have implemented this change so far.

To solve this, two changes are being made:
1. In browsers supports the new spec change to `CSS.supports( "selector()" )`,
   use it before trying `qSA`.
2. Otherwise, add `:has` to the buggy selectors list.

Fixes gh-5098
Closes gh-5107
Ref w3c/csswg-drafts#7676

2 years agoUpgrade: Bump actions/setup-node from 3.3.0 to 3.4.1
dependabot[bot] [Mon, 12 Sep 2022 13:45:20 +0000 (15:45 +0200)]
Upgrade: Bump actions/setup-node from 3.3.0 to 3.4.1

Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3.3.0 to 3.4.1.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v3.3.0...v3.4.1)

Closes gh-5078

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoCore: Drop the root parameter of jQuery.fn.init
Michał Gołębiowski-Owczarek [Mon, 29 Aug 2022 17:03:12 +0000 (19:03 +0200)]
Core: Drop the root parameter of jQuery.fn.init

The third parameter of `jQuery.fn.init` - `root` - was just needed to support
`jQuery.sub`. Since this API has been removed in jQuery 1.9.0 and Migrate 3.x
is not filling it in, this parameter is no longer needed.

This parameter has never been documented but it's safer to remove it in a major
update.

Closes gh-5096

2 years agoTests: Fix the link to QUnit CSS file
Michał Gołębiowski-Owczarek [Mon, 29 Aug 2022 15:44:10 +0000 (17:44 +0200)]
Tests: Fix the link to QUnit CSS file

Without this fix, the layout is fine during the test run but all the CSS is gone
when tests finish and the results are shown.

This affects commands like `grunt karma:chrome-debug`.

Closes gh-5090

2 years agoDocs: Remove git.io from a GitHub Actions comment
Baoshuo Ren [Tue, 12 Jul 2022 15:27:04 +0000 (23:27 +0800)]
Docs: Remove git.io from a GitHub Actions comment

All links on git.io are deprecated and may stop redirecting at a certain point.

See https://github.blog/changelog/2022-04-25-git-io-deprecation/

Closes gh-5036

2 years agoDocs: Update webpack website in README
Simon Legner [Tue, 12 Jul 2022 15:16:24 +0000 (17:16 +0200)]
Docs: Update webpack website in README

Webpack has migrated to https://webpack.js.org/ since version 2.

Closes gh-5037

2 years agoTests: Exclude tests based on compilation flags, not API presence
Michał Gołębiowski-Owczarek [Tue, 28 Jun 2022 10:39:01 +0000 (12:39 +0200)]
Tests: Exclude tests based on compilation flags, not API presence

Introduces a new test API, `includesModule`. The method returns whether
a particular module like "ajax" or "deprecated" is included in the current
jQuery build; it handles the slim build as well. The util was created so that
we don't treat presence of particular APIs to decide whether to run a test as
then if we accidentally remove an API, the tests would still not fail.

Fixes gh-5069
Closes gh-5046

2 years agoBuild: Update GitHub Actions
Michał Gołębiowski-Owczarek [Mon, 27 Jun 2022 16:53:31 +0000 (18:53 +0200)]
Build: Update GitHub Actions

* Build(deps): Bump github/codeql-action from 1 to 2

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 1 to 2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v1...v2)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

* Build(deps): Bump actions/cache from 2 to 3

Bumps [actions/cache](https://github.com/actions/cache) from 2 to 3.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

* Build(deps): Bump actions/setup-node from 2.1.2 to 3.3.0

Bumps [actions/setup-node](https://github.com/actions/setup-node) from 2.1.2 to 3.3.0.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v2.1.2...v3.3.0)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-type: direct:production
  update-type: version-update:semver-major
...

* Build(deps): Bump actions/checkout from 2 to 3

Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Closes gh-5067

2 years agoBuild: Add dependabot.yml config (GitHub Actions)
Christian Oliff [Mon, 27 Jun 2022 16:33:41 +0000 (01:33 +0900)]
Build: Add dependabot.yml config (GitHub Actions)

This makes dependabot issue automated PRs to update
GitHub Action versions monthly.

Closes gh-5057

2 years agoDocs: add link to patchwelcome and help wanted issues
Timmy Willison [Mon, 27 Jun 2022 16:15:59 +0000 (12:15 -0400)]
Docs: add link to patchwelcome and help wanted issues

2 years agoBuild: Test on Node 17, update Grunt & `karma-*` packages
Michał Gołębiowski-Owczarek [Mon, 14 Mar 2022 16:58:41 +0000 (17:58 +0100)]
Build: Test on Node 17, update Grunt & `karma-*` packages

This adds testing on Node.js 17 in addition to the currently tested 10, 12, 14
and 16 versions.

Also, update Grunt & `karma-*` packages.

Testing in Karma on jsdom is broken in Node 17 at the moment; until we find
a fix, this change disables such testing on Node 17 or newer.

Node smoke tests & promises aplus tests are disabled on Node.js 10 as they
depend on jsdom and the latest jsdom version doesn't run properly on Node 10.

Closes gh-5023

2 years agoEffects: Remove jQuery.fx.interval
Michał Gołębiowski-Owczarek [Tue, 1 Mar 2022 13:11:50 +0000 (14:11 +0100)]
Effects: Remove jQuery.fx.interval

`jQuery.fx.interval` has been deprecated since jQuery 3.0.0 but it has been
still used in jQuery code until this change. This commit removes the definition
and explicitly uses the `13` number in its place.

Closes gh-5017

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