aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2023-06-12 22:58:55 +0200
committerGitHub <noreply@github.com>2023-06-12 22:58:55 +0200
commit338de3599039a3ba906214e656bcbe637430c37d (patch)
tree8e7e9f0c3b9e75e2a8b97596c0c6809a2953229c /src
parent27303c6be09b8fc24c13454deae234e480cbf995 (diff)
downloadjquery-338de3599039a3ba906214e656bcbe637430c37d.tar.gz
jquery-338de3599039a3ba906214e656bcbe637430c37d.zip
Selector: Re-expose jQuery.find.{tokenize,select,compile,setDocument}
`Sizzle.tokenize` is an internal Sizzle API, but exposed. As a result, it has historically been available in jQuery via `jQuery.find.tokenize`. That got dropped during Sizzle removal; this change restores the API. Some other APIs so far only exposed on the `3.x` line are also added back: * `jQuery.find.select` * `jQuery.find.compile` * `jQuery.find.setDocument` In addition to that, Sizzle tests have been backported for the following APIs: * `jQuery.find.matchesSelector` * `jQuery.find.matches` * `jQuery.find.compile` * `jQuery.find.select` A new test was also added for `jQuery.find.tokenize` - even Sizzle was missing one. Fixes gh-5259 Closes gh-5263 Ref gh-5260 Ref jquery/sizzle#242 Ref gh-5113 Ref gh-4395 Ref gh-4406
Diffstat (limited to 'src')
-rw-r--r--src/selector-native.js11
-rw-r--r--src/selector.js7
2 files changed, 13 insertions, 5 deletions
diff --git a/src/selector-native.js b/src/selector-native.js
index 07da6f37a..5eb582cfd 100644
--- a/src/selector-native.js
+++ b/src/selector-native.js
@@ -24,10 +24,6 @@
import jQuery from "./core.js";
import document from "./var/document.js";
import whitespace from "./var/whitespace.js";
-
-// The following utils are attached directly to the jQuery object.
-import "./selector/escapeSelector.js";
-import "./selector/uniqueSort.js";
import isIE from "./var/isIE.js";
import booleans from "./selector/var/booleans.js";
import rleadingCombinator from "./selector/var/rleadingCombinator.js";
@@ -40,6 +36,10 @@ import preFilter from "./selector/preFilter.js";
import tokenize from "./selector/tokenize.js";
import toSelector from "./selector/toSelector.js";
+// The following utils are attached directly to the jQuery object.
+import "./selector/escapeSelector.js";
+import "./selector/uniqueSort.js";
+
var matchExpr = jQuery.extend( {
bool: new RegExp( "^(?:" + booleans + ")$", "i" ),
needsContext: new RegExp( "^" + whitespace + "*[>+~]" )
@@ -142,5 +142,6 @@ jQuery.extend( jQuery.find, {
},
matchesSelector: function( elem, expr ) {
return matches.call( elem, expr );
- }
+ },
+ tokenize: tokenize
} );
diff --git a/src/selector.js b/src/selector.js
index c995a65fe..52e975c90 100644
--- a/src/selector.js
+++ b/src/selector.js
@@ -1362,4 +1362,11 @@ setDocument();
jQuery.find = find;
+// These have always been private, but they used to be documented as part of
+// Sizzle so let's maintain them for now for backwards compatibility purposes.
+find.compile = compile;
+find.select = select;
+find.setDocument = setDocument;
+find.tokenize = tokenize;
+
} )();