From 53cf7244da2a2040333335c36e435b1c12efdff9 Mon Sep 17 00:00:00 2001 From: Michał Gołębiowski-Owczarek Date: Wed, 20 Sep 2023 02:31:35 +0200 Subject: CSS:Selector: Align with 3.x, remove the outer `selector.js` wrapper Bring some changes from `3.x-stable`: * rename `rtrim` to `rtrimCSS` to distinguish from the previous `rtrim` regex used for `jQuery.trim` * backport one `id` selector test that avoids the selector engine path Other changes: * remove the inner function wrapper from `selector.js` by renaming the imported `document.js` value * use `jQuery.error` in `selectorError` * make Selector tests pass in all-modules runs by fixing a sinon mistake in Core tests - Core tests had a spy set up for `jQuery.error` that wasn't cleaned up, influencing Selector tests when all were run together Closes gh-5295 --- src/selector/rbuggyQSA.js | 2 ++ src/selector/selectorError.js | 4 +++- src/selector/tokenize.js | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/selector') diff --git a/src/selector/rbuggyQSA.js b/src/selector/rbuggyQSA.js index 7e4632c7f..b056ffe75 100644 --- a/src/selector/rbuggyQSA.js +++ b/src/selector/rbuggyQSA.js @@ -2,6 +2,8 @@ import { isIE } from "../var/isIE.js"; import { whitespace } from "../var/whitespace.js"; import { support } from "./support.js"; +// Build QSA regex. +// Regex strategy adopted from Diego Perini. export var rbuggyQSA = []; if ( isIE ) { diff --git a/src/selector/selectorError.js b/src/selector/selectorError.js index 69770ec6a..da2b239f9 100644 --- a/src/selector/selectorError.js +++ b/src/selector/selectorError.js @@ -1,3 +1,5 @@ +import { jQuery } from "../core.js"; + export function selectorError( msg ) { - throw new Error( "Syntax error, unrecognized expression: " + msg ); + jQuery.error( "Syntax error, unrecognized expression: " + msg ); } diff --git a/src/selector/tokenize.js b/src/selector/tokenize.js index 3c1e06c46..fb25cb207 100644 --- a/src/selector/tokenize.js +++ b/src/selector/tokenize.js @@ -1,7 +1,7 @@ import { jQuery } from "../core.js"; import { rcomma } from "./var/rcomma.js"; import { rleadingCombinator } from "./var/rleadingCombinator.js"; -import { rtrim } from "../var/rtrim.js"; +import { rtrimCSS } from "../var/rtrimCSS.js"; import { createCache } from "./createCache.js"; import { selectorError } from "./selectorError.js"; import { filterMatchExpr } from "./filterMatchExpr.js"; @@ -42,7 +42,7 @@ export function tokenize( selector, parseOnly ) { value: matched, // Cast descendant combinators to space - type: match[ 0 ].replace( rtrim, " " ) + type: match[ 0 ].replace( rtrimCSS, " " ) } ); soFar = soFar.slice( matched.length ); } -- cgit v1.2.3