Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit53cf724

Browse files
authored
CSS:Selector: Align with 3.x, remove the outerselector.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 pathOther 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 togetherClosesgh-5295
1 parent5f86959 commit53cf724

File tree

8 files changed

+39
-23
lines changed

8 files changed

+39
-23
lines changed

‎src/css/curCSS.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { jQuery } from "../core.js";
22
import{isAttached}from"../core/isAttached.js";
33
import{getStyles}from"./var/getStyles.js";
44
import{rcustomProp}from"./var/rcustomProp.js";
5-
import{rtrim}from"../var/rtrim.js";
5+
import{rtrimCSS}from"../var/rtrimCSS.js";
66

77
exportfunctioncurCSS(elem,name,computed){
88
varret,
@@ -41,12 +41,12 @@ export function curCSS( elem, name, computed ) {
4141
// allowing us to differentiate them without a performance penalty
4242
// and returning `undefined` aligns with older jQuery.
4343
//
44-
//rtrim treats U+000D CARRIAGE RETURN and U+000C FORM FEED
44+
//rtrimCSS treats U+000D CARRIAGE RETURN and U+000C FORM FEED
4545
// as whitespace while CSS does not, but this is not a problem
4646
// because CSS preprocessing replaces them with U+000A LINE FEED
4747
// (which *is* CSS whitespace)
4848
// https://www.w3.org/TR/css-syntax-3/#input-preprocessing
49-
ret=ret.replace(rtrim,"$1")||undefined;
49+
ret=ret.replace(rtrimCSS,"$1")||undefined;
5050
}
5151

5252
if(ret===""&&!isAttached(elem)){

‎src/selector.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import{jQuery}from"./core.js";
22
import{nodeName}from"./core/nodeName.js";
3-
import{document}from"./var/document.js";
3+
import{documentaspreferredDoc}from"./var/document.js";
44
import{indexOf}from"./var/indexOf.js";
55
import{pop}from"./var/pop.js";
66
import{push}from"./var/push.js";
77
import{whitespace}from"./var/whitespace.js";
88
import{rbuggyQSA}from"./selector/rbuggyQSA.js";
9-
import{rtrim}from"./var/rtrim.js";
9+
import{rtrimCSS}from"./var/rtrimCSS.js";
1010
import{isIE}from"./var/isIE.js";
1111
import{identifier}from"./selector/var/identifier.js";
1212
import{booleans}from"./selector/var/booleans.js";
@@ -27,10 +27,6 @@ import { toSelector } from "./selector/toSelector.js";
2727
import"./selector/escapeSelector.js";
2828
import"./selector/uniqueSort.js";
2929

30-
varpreferredDoc=document;
31-
32-
(function(){
33-
3430
vari,
3531
outermostContext,
3632

@@ -167,7 +163,11 @@ function find( selector, context, results, seed ) {
167163

168164
// Outside of IE, if we're not changing the context we can
169165
// use :scope instead of an ID.
170-
if(newContext!==context||isIE){
166+
// Support: IE 11+
167+
// IE sometimes throws a "Permission denied" error when strict-comparing
168+
// two documents; shallow comparisons work.
169+
// eslint-disable-next-line eqeqeq
170+
if(newContext!=context||isIE){
171171

172172
// Capture the context ID, setting it first if necessary
173173
if((nid=context.getAttribute("id"))){
@@ -204,7 +204,7 @@ function find( selector, context, results, seed ) {
204204
}
205205

206206
// All others
207-
returnselect(selector.replace(rtrim,"$1"),context,results,seed);
207+
returnselect(selector.replace(rtrimCSS,"$1"),context,results,seed);
208208
}
209209

210210
/**
@@ -632,7 +632,7 @@ jQuery.expr = {
632632
// spaces as combinators
633633
varinput=[],
634634
results=[],
635-
matcher=compile(selector.replace(rtrim,"$1"));
635+
matcher=compile(selector.replace(rtrimCSS,"$1"));
636636

637637
returnmatcher[jQuery.expando] ?
638638
markFunction(function(seed,matches,_context,xml){
@@ -1070,7 +1070,12 @@ function matcherFromTokens( tokens ) {
10701070
returnindexOf.call(checkContext,elem)>-1;
10711071
},implicitRelative,true),
10721072
matchers=[function(elem,context,xml){
1073-
varret=(!leadingRelative&&(xml||context!==outermostContext))||(
1073+
1074+
// Support: IE 11+
1075+
// IE sometimes throws a "Permission denied" error when strict-comparing
1076+
// two documents; shallow comparisons work.
1077+
// eslint-disable-next-line eqeqeq
1078+
varret=(!leadingRelative&&(xml||context!=outermostContext))||(
10741079
(checkContext=context).nodeType ?
10751080
matchContext(elem,context,xml) :
10761081
matchAnyContext(elem,context,xml));
@@ -1104,7 +1109,7 @@ function matcherFromTokens( tokens ) {
11041109
// If the preceding token was a descendant combinator, insert an implicit any-element `*`
11051110
tokens.slice(0,i-1)
11061111
.concat({value:tokens[i-2].type===" " ?"*" :""})
1107-
).replace(rtrim,"$1"),
1112+
).replace(rtrimCSS,"$1"),
11081113
matcher,
11091114
i<j&&matcherFromTokens(tokens.slice(i,j)),
11101115
j<len&&matcherFromTokens((tokens=tokens.slice(j))),
@@ -1369,6 +1374,4 @@ find.select = select;
13691374
find.setDocument=setDocument;
13701375
find.tokenize=tokenize;
13711376

1372-
})();
1373-
13741377
export{jQuery,jQueryas$};

‎src/selector/rbuggyQSA.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { isIE } from "../var/isIE.js";
22
import{whitespace}from"../var/whitespace.js";
33
import{support}from"./support.js";
44

5+
// Build QSA regex.
6+
// Regex strategy adopted from Diego Perini.
57
exportvarrbuggyQSA=[];
68

79
if(isIE){

‎src/selector/selectorError.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import{jQuery}from"../core.js";
2+
13
exportfunctionselectorError(msg){
2-
thrownewError("Syntax error, unrecognized expression: "+msg);
4+
jQuery.error("Syntax error, unrecognized expression: "+msg);
35
}

‎src/selector/tokenize.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import{jQuery}from"../core.js";
22
import{rcomma}from"./var/rcomma.js";
33
import{rleadingCombinator}from"./var/rleadingCombinator.js";
4-
import{rtrim}from"../var/rtrim.js";
4+
import{rtrimCSS}from"../var/rtrimCSS.js";
55
import{createCache}from"./createCache.js";
66
import{selectorError}from"./selectorError.js";
77
import{filterMatchExpr}from"./filterMatchExpr.js";
@@ -42,7 +42,7 @@ export function tokenize( selector, parseOnly ) {
4242
value:matched,
4343

4444
// Cast descendant combinators to space
45-
type:match[0].replace(rtrim," ")
45+
type:match[0].replace(rtrimCSS," ")
4646
});
4747
soFar=soFar.slice(matched.length);
4848
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import{whitespace}from"./whitespace.js";
22

3-
exportvarrtrim=newRegExp(
3+
exportvarrtrimCSS=newRegExp(
44
"^"+whitespace+"+|((?:^|[^\\\\])(?:\\\\.)*)"+whitespace+"+$",
55
"g"
66
);

‎test/unit/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ QUnit.testUnlessIE( "jQuery.parseXML - error reporting", function( assert ) {
14601460

14611461
varerrorArg,lineMatch,line,columnMatch,column;
14621462

1463-
sinon.stub(jQuery,"error");
1463+
this.sandbox.stub(jQuery,"error");
14641464

14651465
jQuery.parseXML("<p>Not a <<b>well-formed</b> xml string</p>");
14661466
errorArg=jQuery.error.firstCall.lastArg.toLowerCase();

‎test/unit/selector.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ QUnit.test( "broken selectors throw", function( assert ) {
226226
});
227227

228228
QUnit.test("id",function(assert){
229-
assert.expect(34);
229+
assert.expect(35);
230230

231-
varfiddle,a;
231+
varfiddle,a,lengthtest;
232232

233233
assert.t("ID Selector","#body",["body"]);
234234
assert.t("ID Selector w/ Element","body#body",["body"]);
@@ -283,6 +283,15 @@ QUnit.test( "id", function( assert ) {
283283

284284
assert.t("ID Selector on Form with an input that has a name of 'id'","#lengthtest",["lengthtest"]);
285285

286+
// Run the above test again but with `jQuery.find` directly to avoid the jQuery
287+
// quick path that avoids running the selector engine.
288+
lengthtest=jQuery.find("#lengthtest");
289+
assert.strictEqual(
290+
lengthtest&&lengthtest[0],
291+
document.getElementById("lengthtest"),
292+
"ID Selector on Form with an input that has a name of 'id' - no quick path (#lengthtest)"
293+
);
294+
286295
assert.t("ID selector with non-existent ancestor","#asdfasdf #foobar",[]);// bug trac-986
287296

288297
assert.deepEqual(jQuery("div#form",document.body).get(),[],

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp