aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2023-09-20 02:31:35 +0200
committerGitHub <noreply@github.com>2023-09-20 02:31:35 +0200
commit53cf7244da2a2040333335c36e435b1c12efdff9 (patch)
tree5331bd464dcc51d7ff1b923ccd5868a733c18234 /test
parent5f869590924b7dea6a16d176b18700939f4b5290 (diff)
downloadjquery-53cf7244da2a2040333335c36e435b1c12efdff9.tar.gz
jquery-53cf7244da2a2040333335c36e435b1c12efdff9.zip
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
Diffstat (limited to 'test')
-rw-r--r--test/unit/core.js2
-rw-r--r--test/unit/selector.js13
2 files changed, 12 insertions, 3 deletions
diff --git a/test/unit/core.js b/test/unit/core.js
index 666f0e820..aa1f637dd 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -1460,7 +1460,7 @@ QUnit.testUnlessIE( "jQuery.parseXML - error reporting", function( assert ) {
var errorArg, lineMatch, line, columnMatch, column;
- sinon.stub( jQuery, "error" );
+ this.sandbox.stub( jQuery, "error" );
jQuery.parseXML( "<p>Not a <<b>well-formed</b> xml string</p>" );
errorArg = jQuery.error.firstCall.lastArg.toLowerCase();
diff --git a/test/unit/selector.js b/test/unit/selector.js
index cf36b1dbb..d6f28e25b 100644
--- a/test/unit/selector.js
+++ b/test/unit/selector.js
@@ -226,9 +226,9 @@ QUnit.test( "broken selectors throw", function( assert ) {
} );
QUnit.test( "id", function( assert ) {
- assert.expect( 34 );
+ assert.expect( 35 );
- var fiddle, a;
+ var fiddle, a, lengthtest;
assert.t( "ID Selector", "#body", [ "body" ] );
assert.t( "ID Selector w/ Element", "body#body", [ "body" ] );
@@ -283,6 +283,15 @@ QUnit.test( "id", function( assert ) {
assert.t( "ID Selector on Form with an input that has a name of 'id'", "#lengthtest", [ "lengthtest" ] );
+ // Run the above test again but with `jQuery.find` directly to avoid the jQuery
+ // quick path that avoids running the selector engine.
+ lengthtest = jQuery.find( "#lengthtest" );
+ assert.strictEqual(
+ lengthtest && lengthtest[ 0 ],
+ document.getElementById( "lengthtest" ),
+ "ID Selector on Form with an input that has a name of 'id' - no quick path (#lengthtest)"
+ );
+
assert.t( "ID selector with non-existent ancestor", "#asdfasdf #foobar", [] ); // bug trac-986
assert.deepEqual( jQuery( "div#form", document.body ).get(), [],