🌐 AI搜索 & 代理 主页
Skip to content

Commit 5817baa

Browse files
mgolgibson042
andcommitted
Selector: Reword a few comments
Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
1 parent 8b5ef0e commit 5817baa

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/selector/rbuggyQSA.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ if ( isIE ) {
2424
if ( !support.cssHas ) {
2525

2626
// Support: Chrome 105 - 110+, Safari 15.4 - 16.3+
27-
// In some browsers, `:has()` uses a forgiving selector list as an argument,
28-
// so our regular `try-catch` mechanism fails to catch `:has()` with arguments
29-
// not supported natively, like `:has(:contains("Foo"))`. The spec now requires
30-
// `:has()` parsing to be non-forgiving but browsers have not adjusted yet.
27+
// Our regular `try-catch` mechanism fails to detect natively-unsupported
28+
// pseudo-classes inside `:has()` (such as `:has(:contains("Foo"))`)
29+
// in browsers that parse the `:has()` argument as a forgiving selector list.
30+
// https://drafts.csswg.org/selectors/#relational now requires the argument
31+
// to be parsed unforgivingly, but browsers have not yet fully adjusted.
3132
rbuggyQSA.push( ":has" );
3233
}
3334

src/selector/support.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import document from "../var/document.js";
22
import support from "../var/support.js";
33

44
// Support: Chrome 105 - 110+, Safari 15.4 - 16.3+
5-
// Make sure forgiving mode is not used in `:has()`.
6-
// `*` is needed as Safari & newer Chrome implemented something in between
7-
// for `:has()` - it throws in `qSA` if it only contains an unsupported
8-
// argument but multiple ones, one of which is supported, are fine.
9-
// We want to play safe in case `:is()` gets the same treatment.
10-
//
11-
// Note that we don't need to detect the complete lack of support for `:has()`
12-
// as then the `qSA` path will throw and fall back to jQuery traversal anyway.
5+
// Make sure the the `:has()` argument is parsed unforgivingly.
6+
// We include `*` in the test to detect buggy implementations that are
7+
// _selectively_ forgiving (specifically when the list includes at least
8+
// one valid selector).
9+
// Note that we treat complete lack of support for `:has()` as if it were
10+
// spec-compliant support, which is fine because use of `:has()` in such
11+
// environments will fail in the qSA path and fall back to jQuery traversal
12+
// anyway.
1313
try {
1414
document.querySelector( ":has(*,:jqfake)" );
1515
support.cssHas = false;

0 commit comments

Comments
 (0)