Commit Graph

160 Commits

Author SHA1 Message Date
Michał Gołębiowski-Owczarek
d153c375e6
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
2022-09-19 20:56:02 +02:00
Bruno PIERRE
9c6f64c7b5
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
2022-01-24 18:55:16 +01:00
Michał Gołębiowski-Owczarek
eb9ceb2fac
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
2022-01-12 23:23:42 +01:00
Michał Gołębiowski-Owczarek
5d5ea01511
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
2022-01-04 16:27:18 +01:00
Michał Gołębiowski-Owczarek
50e8e84621
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
2021-04-13 22:11:45 +02:00
Michał Gołębiowski-Owczarek
e35fb62db4
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
2020-09-22 17:49:28 +02:00
Michał Gołębiowski-Owczarek
90fed4b453
Manipulation: Make jQuery.htmlPrefilter an identity function
Closes gh-4642
2020-03-16 21:49:29 +01:00
Michał Gołębiowski-Owczarek
c1ee33aded
Selector: Remove the "a:enabled" workaround for Chrome <=77
Remove the workaround for a broken `:enabled` pseudo-class on anchor elements
in Chrome <=77. These versions of Chrome considers anchor elements with the
`href` attribute as matching `:enabled`.

Closes gh-4569
2019-12-16 19:43:38 +01:00
Michał Gołębiowski-Owczarek
341c6d1b5a
Build: Make Karma work in ES modules mode
Also, run such a suite in CI to make sure modules are working as expected
when used directly.

Closes gh-4550
2019-12-16 19:33:49 +01:00
Michał Gołębiowski-Owczarek
05184cc448
Selector: Make empty attribute selectors work in IE 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.

Fixes gh-4435
Closes gh-4510
2019-11-18 22:10:55 +01:00
Michał Gołębiowski-Owczarek
f09d92100f
Docs: Update most URLs to HTTPS
Closes gh-4511
2019-10-21 19:03:48 +02:00
Michał Gołębiowski-Owczarek
6eee5f7f18
Selector: Add a test for throwing on post-comma invalid selectors
Sizzle's PR jquery/sizzle#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 failed, making Opera fail quicker and not adding
a post-comma invalid selector to rbuggyQSA.

The issue was fixed in jquery/sizzle#463. This jQuery commit backports the test
that Sizzle PR added as no workarounds are needed in browsers jQuery supports.

Closes gh-4516
Ref jquery/sizzle#456
Ref jquery/sizzle#463
2019-10-21 19:03:03 +02:00
Michał Gołębiowski-Owczarek
1d624c10b4
Tests: Stop using jQuery.find in tests
This prepares us for possibly hiding jQuery.find in jQuery 4.0.

Closes gh-4517
2019-10-21 19:02:22 +02:00
Michał Gołębiowski-Owczarek
29a9544a4f
Selector: reduce size, simplify setDocument
With new selector code doing less convoluted support tests, it was possible
to extract a lot of logic out of setDocument & also reduce size.

This commit also backports jquery/sizzle#439 that was reverted by mistake
during a switch from JSHint + JSCS to ESLint.

Closes gh-4462
Ref jquery/sizzle#442
Ref jquery/sizzle#439
2019-08-26 19:15:53 +02:00
Richard Gibson
ac5f7cd8e2
Tests: Port changes from Sizzle
Ref https://github.com/jquery/sizzle/pull/450
Closes gh-4464
2019-08-20 14:05:37 -04:00
Michał Gołębiowski-Owczarek
df6a7f7f0f
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 gh-4453
Closes gh-4454
Ref gh-4332
Ref jquery/sizzle#405
2019-08-19 18:41:03 +02:00
Michał Gołębiowski-Owczarek
47835965bd Selector: Inline Sizzle into the selector module
This commit removes Sizzle from jQuery, inlining its code & removing obsolete
workarounds where applicable.

The selector-native module has been removed. Further work on the selector
module may decrease the size enough that it will no longer be necessary. If
it turns out it's still useful, we'll reinstate it but the code will look
different anyway as we'll want to share as much code as possible with
the existing selector module.

The Sizzle AUTHORS.txt file has been merged with the jQuery one - people are
sorted by their first contributions to either of the two repositories.

The commit reduces the gzipped jQuery size by 1460 bytes compared to master.

Closes gh-4395
2019-07-29 21:19:21 +02:00
Michał Gołębiowski-Owczarek
79b74e043a
Selector: Port Sizzle tests to jQuery
Apart from porting most Sizzle tests to jQuery (mostly to its selector module),
this commit fixes selector-native so that a jQuery custom compilation that
excludes Sizzle passes all tests as well.

Closes gh-4406
2019-06-26 21:39:10 +02:00
abnud1
c349818742 Build: Update test code for compatibility with QUnit 2.x (#4297)
Also, run `grunt npmcopy` to sync the "external" directory with dependencies
from package.json. For example, the Sinon library version didn't match.

Ref gh-4234
Closes gh-4297
2019-02-18 19:03:26 +01:00
Oleg Gaidarenko
58c6ca9822 Build: ESLint details
Use eslint pragmas, fix new errors, etc

Closes gh-3148
2016-06-11 10:41:33 +03:00
Dave Methvin
e5ffcb0838 Tests: Refactor testIframe() to make it DRYer and more consistent
Ref gh-3040
Closes gh-3049
2016-04-11 13:32:51 -04:00
Dave Methvin
08d73d7f9c Tests: Make iframe tests wait after checking isReady
Ref gh-3040
2016-04-11 13:29:11 -04:00
Alexander Lisianoi
59ec78e602 Tests: Restrict "p > * > *" selection in selector.js to #qunit-fixture
Add `match` and `QUnit.assert.selectInFixture` functions that
mimic `QUnit.assert.t`.

Ref gh-2880
Closes gh-2973
2016-03-09 14:09:20 -05:00
Timmy Willison
25068bf2c6 Selector: add jQuery.escapeSelector
Fixes gh-1761
Close gh-2878
2016-01-28 17:25:41 -05:00
Timmy Willison
88046440da Selector: pass jQuery unit tests with selector-native
- Ignore certain tests that obviously are not supported
- Beefed up the sortOrder, uniqueSort, isXMLDoc, and attr functions

Fixes gh-1742
Fixes gh-2048
Close gh-2703
2015-11-11 10:10:10 -05:00
Gary Ye
03eaadb131 Tests:Docs: Fix various typos
* Changes "baar" to "bar" when used with "foo" in readme
  and comments of js files

* mousenter -> mouseenter

Thanks @garysye, @KimTaehee

Closes gh-2613
Closes gh-2601
2015-10-12 18:08:13 +03:00
Oleg Gaidarenko
c8d15a2f9f Tests: further improvements QUnit 2.0 migration
* Remove QUnit jshint globals
* Extend QUnit.assert methods
* Use assert.async instead of start/stop/done

Ref b930d14ce6
2015-09-08 04:06:20 +03:00
Oleg Gaidarenko
10fdad742a Build: Update jscs and lint files
Fixes gh-2056
2015-09-07 20:03:50 +03:00
Oleg Gaidarenko
b930d14ce6 Tests: partially use new qunit interface
http://qunitjs.com/upgrade-guide-2.x/

For most of the boring work was used
https://github.com/apsdehal/qunit-migrate package

However, it can't update local qunit helpers, plus in some places
old QUnit.asyncTest signature is still used

Fixes gh-2540
2015-08-16 09:02:01 +03:00
Timmy Willison
add85afed5 Selector: add test for jQuery.unique() alias 2015-05-05 07:59:12 -07:00
Timmy Willison
e1090c3d2b Selector: add jQuery.uniqueSort; deprecate jQuery.unique
Fixes gh-2228
2015-05-04 15:27:12 -07:00
Oleg Gaidarenko
dc4b914a05 Build: Fix various typos
Thanks @jamesgpearce, @vlajos, @imyousuf
Closes gh-1828
Closes gh-1830
Closes gh-1844
2014-11-08 17:24:33 +03:00
Michał Gołębiowski
86e62d8b37 Selector: Remove "#" exception for identifier tokens
Port Sizzle test change from:
f204a61122
2014-06-30 18:13:57 +02:00
Oleg Gaidarenko
3b9057a18d Selector: Use jQuery reference not Sizzle 2014-05-29 21:54:45 +04:00
Oleg Gaidarenko
efc4f8d781 Selector: Fix test iframe submission for firefox
Ref jquery/sizzle@20fbadb087
2014-05-29 21:45:59 +04:00
Oleg Gaidarenko
4f14bea2c2 Tests: Remove unused variables 2014-04-15 17:46:00 +04:00
Oleg Gaidarenko
80ea65edf7 Tests: Copy some Sizzle combinators tests 2014-04-15 17:45:59 +04:00
Oleg Gaidarenko
8084ab24bc Tests: Add more tests for Sizzle attributes 2014-04-15 17:45:59 +04:00
Oleg Gaidarenko
d7af36676b Tests: Add test for selectors with commas 2014-04-15 17:45:59 +04:00
Oleg Gaidarenko
3115d4c92d Tests: Copy Sizzle.uniqueSort tests 2014-04-15 17:45:59 +04:00
Oleg Gaidarenko
c63d1da7cd Tests: Copy Sizzle.contains tests 2014-04-15 17:45:59 +04:00
Oleg Gaidarenko
81aa237ee1 Tests: Move some of the Sizzle tests to selector 2014-04-15 17:45:59 +04:00
Michał Gołębiowski
4b39a82890 Fix #14340. Remove remnants of oldIE from unit tests. Close gh-1425. 2013-11-11 00:43:27 +01:00
Dave Methvin
9fdbc8bf33 Fix #13223. Re-allow leading space in HTML. Close gh-1264.
(cherry picked from commit 00eafdf028)
2013-05-09 14:53:15 -04:00
Richard Gibson
5d1dfe7474 Fix #13539: Utilize Sizzle hooks. Close gh-1215.
(cherry picked from commit 4ef516903e)
2013-04-05 00:37:36 -04:00
Richard Gibson
59f5adb622 No ticket: Revise unit tests in anticipation of Sizzle-free builds 2013-02-22 20:13:36 -05:00
Richard Gibson
6971d9d8e2 Fix 363299ac failures 2013-02-07 17:03:04 -05:00
Richard Gibson
363299ac24 Ref #13316: Sync all documents on full vs. minified source. Close gh-1147. 2013-02-07 15:16:28 -05:00
Timmy Willison
b326225d90 Fix failing tests, add support for empty spans in Opera. Supplements #13132, #10406. 2013-01-21 18:03:07 -05:00
Richard Gibson
a763ae7277 Fix #11115: Normalize boolean attributes/properties. Close gh-1066. 2012-12-15 23:16:48 -05:00