aboutsummaryrefslogtreecommitdiffstats
path: root/src/selector/testContext.js
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2023-02-13 18:34:41 +0100
committerGitHub <noreply@github.com>2023-02-13 18:34:41 +0100
commit2e644e845051703775b35b358eec5d3608a9465f (patch)
treef1b17f379cd4875a3f8e60a9d20f2354333ce4d5 /src/selector/testContext.js
parent7e7bd062070b3eca8ee047136ea8575fbed5d70f (diff)
downloadjquery-2e644e845051703775b35b358eec5d3608a9465f.tar.gz
jquery-2e644e845051703775b35b358eec5d3608a9465f.zip
Selector: Backport jQuery selection context logic to selector-native
This makes: ```js $div.find("div > *") ``` no longer matching children of `$div`. Also, leading combinators now work, e.g.: ```js $div.find( "> *" ); ``` returns children of `$div`. As a result of that, a number of tests are no longer skipped in the `selector-native` mode. Also, rename `rcombinators` to `rleadingCombinator`. Fixes gh-5185 Closes gh-5186 Ref gh-5085
Diffstat (limited to 'src/selector/testContext.js')
-rw-r--r--src/selector/testContext.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/selector/testContext.js b/src/selector/testContext.js
new file mode 100644
index 000000000..a54351e64
--- /dev/null
+++ b/src/selector/testContext.js
@@ -0,0 +1,10 @@
+/**
+ * Checks a node for validity as a jQuery selector context
+ * @param {Element|Object=} context
+ * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
+ */
+function testContext( context ) {
+ return context && typeof context.getElementsByTagName !== "undefined" && context;
+}
+
+export default testContext;