From 2e644e845051703775b35b358eec5d3608a9465f Mon Sep 17 00:00:00 2001 From: Michał Gołębiowski-Owczarek Date: Mon, 13 Feb 2023 18:34:41 +0100 Subject: 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 --- src/selector/testContext.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/selector/testContext.js (limited to 'src/selector/testContext.js') 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; -- cgit v1.2.3