Commit Graph

1042 Commits

Author SHA1 Message Date
Michał Gołębiowski-Owczarek
2f1afae2ab
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.

Ref jquery/jquery#5271
Ref jquery/jquery#5277
Ref https://bugzilla.mozilla.org/show_bug.cgi?id=1839747#c1
Ref https://github.com/w3c/csswg-drafts/issues/8720#issuecomment-1509242961
2023-09-07 16:51:31 +02:00
Michał Gołębiowski-Owczarek
4194dc464e
Docs: Update the command to clone the repo 2023-02-14 19:24:56 +01:00
Michał Gołębiowski-Owczarek
ef52300a48
Build: Update another version in package-lock.json 2023-02-14 19:24:04 +01:00
Michał Gołębiowski-Owczarek
31256506b1
Build: Updating the main version to 2.3.11-pre. 2023-02-14 19:00:55 +01:00
Michał Gołębiowski-Owczarek
6d1346a2c1
Build: Update tested browsers 2023-02-14 13:36:51 +01:00
Michał Gołębiowski-Owczarek
15a1238f51
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.

Fixes jquery/jquery#5194
Closes gh-493
Ref jquery/jquery#5098
Ref jquery/jquery#5206
Ref jquery/jquery#5207
Ref gh-486
Ref w3c/csswg-drafts#7676
2023-02-14 13:13:00 +01:00
Michał Gołębiowski-Owczarek
248b59c008
Selector: Rename rcombinators to rleadingCombinator
Closes gh-494
Ref jquery/jquery#5186
Ref jquery/jquery#5208
2023-02-13 18:35:49 +01:00
Michał Gołębiowski-Owczarek
ac08bb9d24
Build: Update tested browsers (add Firefox 108 & Opera 93) 2022-12-19 23:06:57 +01:00
Michał Gołębiowski-Owczarek
c629539e5f
Build: Update another version in package-lock.json 2022-12-19 23:06:05 +01:00
Michał Gołębiowski-Owczarek
c2be7d3575
Build: Updating the main version to 2.3.10-pre. 2022-12-19 18:54:08 +01:00
Michał Gołębiowski-Owczarek
7781b658a5
Selector: Make selector lists work with qSA again
Sizzle 2.3.7 started using `CSS.supports( "selector(SELECTOR)" )` before using
`querySelectorAll` on the selector. This was to solve jquery/jquery#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 Sizzle 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 Sizzle 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 Sizzle 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 jquery/jquery#5177
Closes gh-491
Ref w3c/csswg-drafts#7280
2022-12-19 18:43:07 +01:00
Michał Gołębiowski-Owczarek
b2cb393faf
Build: Update tested browsers
Add Chrome 108, Edge 108, Firefox 107 & Safari 16.

Test some of the browsers on macOS Ventura.
2022-12-15 00:37:10 +01:00
Michał Gołębiowski-Owczarek
f2a2412e5e
Tests: Fix a typo in a Sizzle.contains test description 2022-11-17 14:30:11 +01:00
Michał Gołębiowski-Owczarek
fa4ca25e58
Build: Update package-lock.json again
Apparently, the `version` field is now duplicated inside of `packages[ "" ]`
as well and that one also needs to be updated.
2022-11-17 12:12:08 +01:00
Michał Gołębiowski-Owczarek
670ee53741
Build: Updating the main version to 2.3.9-pre. 2022-11-16 16:45:58 +01:00
Michał Gołębiowski-Owczarek
759acc72af
Core: Make Sizzle.contains work within <template/> elements
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 above behavior made `Sizzle.contains` crash when run on certain elements
within the `<template/>` element. 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.

However, we still need to fall back to `documentElement` if one is
defined as IE <9 have a broken `.contains()` on the document.

Fixes jquery/jquery#5147
Closes gh-490
Ref jquery/jquery#5158
2022-11-16 13:16:47 +01:00
Michał Gołębiowski-Owczarek
30498aa8ad
Build: Update tested browsers
Add Chrome 106/107, Firefox 105/106, Edge 106/107, Opera 91/92.
2022-11-15 14:53:19 +01:00
Michał Gołębiowski-Owczarek
5d37bf7554 Build: Add iOS 16 2022-10-05 00:14:12 +02:00
Michał Gołębiowski-Owczarek
0a8f983379 Build: Update Grunt, fix package-lock.json 2022-10-03 23:43:16 +02:00
Michał Gołębiowski-Owczarek
0dda4e01d0 Build: Update package-lock.json 2022-10-03 23:40:58 +02:00
Michał Gołębiowski-Owczarek
8c70695b4f Build: Updating the main version to 2.3.8-pre. 2022-10-03 23:31:50 +02:00
Michał Gołębiowski-Owczarek
8abe9d220b
Tests: Run Sizzle.uniqueSort on a copy of an input
Avoid modifying input in the first `Sizze.uniqueSort` test by ensuring a copy
of the test input is provided.

Closes gh-488
2022-10-03 18:21:38 +02:00
Michał Gołębiowski-Owczarek
d0764e06f1
Tests: Test Sizzle.isXML, not jQuery.isXMLDoc
By mistake, the jQuery API has been tested instead of the Sizzle one.

Closes gh-487
2022-09-19 23:36:23 +02:00
Michał Gołębiowski-Owczarek
3798e3d7fa
Selector: Use Sizzle :has if CSS.supports(selector(...)) non-compliant
Sizzle 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 Sizzle 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 jquery/jquery#5098
Closes gh-486
Ref jquery/jquery#5107
Ref w3c/csswg-drafts#7676
2022-09-19 21:21:34 +02:00
Michał Gołębiowski-Owczarek
d3af661e7d
Build: Update tested browsers
Closes gh-485
2022-09-15 16:36:47 +03:00
Michał Gołębiowski-Owczarek
3751e621fd Tests: Fix an incorrect issue reference 2022-09-05 18:35:40 +02:00
Michał Gołębiowski-Owczarek
ede0e97563
Tests: Migrate from Travis to GitHub Actions
Closes gh-482
2022-01-10 18:08:58 +01:00
Michał Gołębiowski-Owczarek
20390f0573 Build: Updating the main version to 2.3.7-pre. 2021-02-16 14:57:56 +01:00
Michał Gołębiowski-Owczarek
0ec7ccf957 Build: Fix the link to AUTHORS.txt 2021-02-16 14:32:43 +01:00
Michał Gołębiowski-Owczarek
9cb6739356 Build: Update tested browsers 2021-02-16 14:31:24 +01:00
Michał Gołębiowski-Owczarek
344ae8f096 Build: Remove a deprecated sudo: false key from .travis.yml 2021-02-16 14:25:15 +01:00
Michał Gołębiowski-Owczarek
23189b76e3 Build: Update tested browsers 2020-12-07 21:48:53 +01:00
Michał Gołębiowski-Owczarek
9987cb3edb
Core: Make Sizzle.isXML accept falsy input
Fixes jquery/jquery#4782
Closes gh-474
Ref jquery/jquery#4814
2020-12-07 21:08:40 +01:00
Michał Gołębiowski-Owczarek
f441747f80 Build: Update version in package-lock.json to 2.3.6-pre 2020-12-01 14:31:35 +01:00
Michał Gołębiowski-Owczarek
390f24005f
Build: Remove the version field from the bower.json file
jquery-release only updates the version in the tag so it stays stale on master.
Instead, just remove the version from there.

Closes gh-469
2020-03-30 18:09:59 +02:00
Michał Gołębiowski-Owczarek
bfb7b5ed06 Build: Updating the master version to 2.3.6-pre. 2020-03-14 00:18:07 +01:00
Michał Gołębiowski-Owczarek
096f6836d4
Release: Make Sizzle work with jquery-release, remove generated files
Running `grunt` will now just build Sizzle, do a size comparison & run ESLint,
similarly to what we do in jQuery. `grunt test` is used to run unit tests and
it requires running `grunt` or `grunt build` before to generate the built
Sizzle version.

Fixes gh-239
Closes gh-467
2020-03-02 20:29:32 +01:00
Michał Gołębiowski-Owczarek
6812dd07a7 Release: Update AUTHORS.txt 2020-02-28 18:53:00 +01:00
Michał Gołębiowski-Owczarek
af163873d7
Selector: Make empty attribute selectors work in IE 11/Edge again
qSA in IE 11/Edge often (but not always) don't find elements with an empty
name attribute selector (`[name=""]`). Detect that & fall back to Sizzle
traversal.

Interestingly, IE 10 & older don't seem to have the issue.

Closes gh-461
Fixes jquery/jquery#4435
2019-10-21 18:59:44 +02:00
Michał Gołębiowski-Owczarek
3965b4ad93
Selector: Throw on post-comma invalid selectors in Opera 10-11 again
PR gh-456 introduced a test catching not throwing on badly-escaped identifiers
by Firefox 3.6-5. Unfortunately, it was placed just before a test Opera 10-11
fails, making Opera fail quicker and not adding a post-comma invalid selector
to rbuggyQSA.

This commit fixes the regression & introduces a unit test ensuring the throwing.
Unfortunately, the issue is fixed in Opera 11.6 which is the lowest one Sizzle
officially supports but I verified the fix manually against Opera 10.6, 11.1
& 11.5.

Closes gh-463
Ref gh-456
2019-10-21 18:50:49 +02:00
Michał Gołębiowski-Owczarek
dd774827f3
Tests: Test for Shadow DOM v1 support
There was a test for Shadow DOM nodes working as root but it was using Shadow
DOM v0 that only Chromium implements and which it plans to remove in the future.
The test was reworked to rely on Shadow DOM v1.

jQuery master already uses the new API in its tests.

Closes gh-464
2019-10-21 18:50:26 +02:00
Michał Gołębiowski-Owczarek
102b3d63c1
Build: Update tested browsers, test on Edge 15-18 instead of just 17-18
Closes gh-462
2019-10-15 20:28:55 +02:00
Michał Gołębiowski-Owczarek
a528ae5202
Selector: Make selectors with leading combinators use qSA again
An optimization added in jquery/sizzle#431 skips the temporary IDs for selectors
not using child or descendant combinators. For sibling combinators, though, this
pushes a selector with a leading combinator to qSA directly which crashes and
falls back to a slower Sizzle route.

This commit makes selectors with leading combinators not skip the selector
rewriting. Note that after jquery/jquery#4454 & jquery/sizzle#453, all modern
browsers other than Edge leverage the :scope pseudo-class, avoiding temporary
id attributes.

Closes gh-460
Ref gh-431
2019-10-14 18:26:05 +02:00
Michał Gołębiowski-Owczarek
0f4bd299bd
Selector: Leverage the :scope pseudo-class where possible
The `:scope` pseudo-class[1] has surprisingly good browser support: Chrome,
Firefox & Safari have supported if for a long time; only IE & Edge lack support.
This commit leverages this pseudo-class to get rid of the ID hack in most cases.
Adding a temporary ID may cause layout thrashing which was reported a few times
in [the past.

We can't completely eliminate the ID hack in modern browses as sibling selectors
require us to change context to the parent and then `:scope` stops applying to
what we'd like. But it'd still improve performance in the vast majority of
cases.

[1] https://developer.mozilla.org/en-US/docs/Web/CSS/:scope

Fixes jquery/jquery#4453
Closes gh-453
Ref jquery/jquery#4454
Ref jquery/jquery#4332
Ref gh-405
2019-10-11 01:06:39 +02:00
Michał Gołębiowski-Owczarek
cd0239bf32
Selector: Use shallow document comparisons to avoid IE/Edge cras… (#459)
IE/Edge sometimes crash when comparing documents between frames using the strict
equality operator (`===` & `!==`). Funnily enough, shallow comparisons
(`==` & `!=`) work without crashing.

Fixes jquery/jquery#4441
Closes gh-459
Ref jquery/jquery#4471
2019-10-01 02:38:29 +02:00
Michał Gołębiowski-Owczarek
bdf239729a Build: Split iOS tests into two sets to improve reliability
The Karma version currently used by Sizzle often re-runs tests in all browsers
from the current browser set if one of them fails. To improve reliability, split
iOS into two browser sets similarly to how desktop browsers & Android are split.

Closes gh-457
2019-08-21 17:17:45 -04:00
Michał Gołębiowski-Owczarek
948eff8f0f
Build: Run Karma tests sequentially in separate processes + other improvements
Sizzle hasn't been able to finish all its unit tests successfully for a long time. This commit attempts to make it work again (at least most of the time).

Summary of the changes:
1. A new "karma-tests" task is created; it runs tests in various browser sets
but does it sequentially in separate processes to avoid Karma bugs that cause
browsers from previous sets to somehow still be waited on during subsequent
runs, failing the build.
2. Upgrade tested browsers.
3. Run iOS tests at the end (as it fails more often than other browsers).
4. Use real iOS 10.3 device in Karma.

We can't upgrade Karma as the latest version (`4.2.0`) hangs in IE 7 (IE 8 seems to work fine there).

Closes gh-455
2019-08-21 16:57:14 +02:00
Michał Gołębiowski-Owczarek
11767a18f7 Selector: Detect incorrect escape handling by old Firefox
According to:
https://www.w3.org/TR/css-syntax-3/#ident-token-diagram
the escape doesn't need to be followed by a whitespace only if it's not a hex
digit or a newline. However, old Firefox (3.6 - 5 only) doesn't throw if an
escaped newline is not followed by a space. Fallback to Sizzle in such cases.

Fixes gh-454
Closes gh-456
2019-08-20 23:23:55 +02:00
Michał Gołębiowski-Owczarek
5d90d4fc09 Build: Remove xvfb usage from Travis, run tests on Node.js 12
Closes gh-451
2019-08-19 12:22:39 -04:00
Richard Gibson
b2b650b629 Selector: Allow whitespace after hex escapes in CSS identifiers
Ref jquery/jquery#4424
Closes gh-450
2019-08-19 08:56:46 -04:00