Skip to content

Commit

Permalink
Selector: Reword a few comments
Browse files Browse the repository at this point in the history
Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
  • Loading branch information
mgol and gibson042 committed Feb 13, 2023
1 parent 8b5ef0e commit 5817baa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
9 changes: 5 additions & 4 deletions src/selector/rbuggyQSA.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ if ( isIE ) {
if ( !support.cssHas ) {

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

Expand Down
16 changes: 8 additions & 8 deletions src/selector/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import document from "../var/document.js";
import support from "../var/support.js";

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

0 comments on commit 5817baa

Please sign in to comment.