Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
e70d0d74
Commit
e70d0d74
authored
Feb 05, 2014
by
Michał Gołębiowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Selector: update Sizzle
(cherry-picked from
a74ad04b
)
parent
2f202b03
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
94 additions
and
64 deletions
+94
-64
bower.json
bower.json
+1
-1
sizzle.js
src/sizzle/dist/sizzle.js
+77
-58
sizzle.min.js
src/sizzle/dist/sizzle.min.js
+2
-2
sizzle.min.map
src/sizzle/dist/sizzle.min.map
+1
-1
selector.js
src/sizzle/test/unit/selector.js
+13
-2
No files found.
bower.json
View file @
e70d0d74
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
"bower.json"
"bower.json"
],
],
"dependencies"
:
{
"dependencies"
:
{
"sizzle"
:
"1.10.1
6
"
"sizzle"
:
"1.10.1
8
"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"requirejs"
:
"2.1.10"
,
"requirejs"
:
"2.1.10"
,
...
...
src/sizzle/dist/sizzle.js
View file @
e70d0d74
/*!
/*!
* Sizzle CSS Selector Engine v1.10.1
6
* Sizzle CSS Selector Engine v1.10.1
8
* http://sizzlejs.com/
* http://sizzlejs.com/
*
*
* Copyright 2013 jQuery Foundation, Inc. and other contributors
* Copyright 2013 jQuery Foundation, Inc. and other contributors
* Released under the MIT license
* Released under the MIT license
* http://jquery.org/license
* http://jquery.org/license
*
*
* Date: 2014-0
1-13
* Date: 2014-0
2-05
*/
*/
(
function
(
window
)
{
(
function
(
window
)
{
...
@@ -16,6 +16,7 @@ var i,
...
@@ -16,6 +16,7 @@ var i,
getText
,
getText
,
isXML
,
isXML
,
compile
,
compile
,
select
,
outermostContext
,
outermostContext
,
sortInput
,
sortInput
,
hasDuplicate
,
hasDuplicate
,
...
@@ -137,7 +138,7 @@ var i,
...
@@ -137,7 +138,7 @@ var i,
funescape
=
function
(
_
,
escaped
,
escapedWhitespace
)
{
funescape
=
function
(
_
,
escaped
,
escapedWhitespace
)
{
var
high
=
"0x"
+
escaped
-
0x10000
;
var
high
=
"0x"
+
escaped
-
0x10000
;
// NaN means non-codepoint
// NaN means non-codepoint
// Support: Firefox
// Support: Firefox
<24
// Workaround erroneous numeric interpretation of +"0x"
// Workaround erroneous numeric interpretation of +"0x"
return
high
!==
high
||
escapedWhitespace
?
return
high
!==
high
||
escapedWhitespace
?
escaped
:
escaped
:
...
@@ -1570,6 +1571,15 @@ function elementMatcher( matchers ) {
...
@@ -1570,6 +1571,15 @@ function elementMatcher( matchers ) {
matchers
[
0
];
matchers
[
0
];
}
}
function
multipleContexts
(
selector
,
contexts
,
results
)
{
var
i
=
0
,
len
=
contexts
.
length
;
for
(
;
i
<
len
;
i
++
)
{
Sizzle
(
selector
,
contexts
[
i
],
results
);
}
return
results
;
}
function
condense
(
unmatched
,
map
,
filter
,
context
,
xml
)
{
function
condense
(
unmatched
,
map
,
filter
,
context
,
xml
)
{
var
elem
,
var
elem
,
newUnmatched
=
[],
newUnmatched
=
[],
...
@@ -1838,7 +1848,7 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
...
@@ -1838,7 +1848,7 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
superMatcher
;
superMatcher
;
}
}
compile
=
Sizzle
.
compile
=
function
(
selector
,
group
/* Internal Use Only */
)
{
compile
=
Sizzle
.
compile
=
function
(
selector
,
match
/* Internal Use Only */
)
{
var
i
,
var
i
,
setMatchers
=
[],
setMatchers
=
[],
elementMatchers
=
[],
elementMatchers
=
[],
...
@@ -1846,12 +1856,12 @@ compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
...
@@ -1846,12 +1856,12 @@ compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
if
(
!
cached
)
{
if
(
!
cached
)
{
// Generate a function of recursive functions that can be used to check each element
// Generate a function of recursive functions that can be used to check each element
if
(
!
group
)
{
if
(
!
match
)
{
group
=
tokenize
(
selector
);
match
=
tokenize
(
selector
);
}
}
i
=
group
.
length
;
i
=
match
.
length
;
while
(
i
--
)
{
while
(
i
--
)
{
cached
=
matcherFromTokens
(
group
[
i
]
);
cached
=
matcherFromTokens
(
match
[
i
]
);
if
(
cached
[
expando
]
)
{
if
(
cached
[
expando
]
)
{
setMatchers
.
push
(
cached
);
setMatchers
.
push
(
cached
);
}
else
{
}
else
{
...
@@ -1861,74 +1871,83 @@ compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
...
@@ -1861,74 +1871,83 @@ compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
// Cache the compiled function
// Cache the compiled function
cached
=
compilerCache
(
selector
,
matcherFromGroupMatchers
(
elementMatchers
,
setMatchers
)
);
cached
=
compilerCache
(
selector
,
matcherFromGroupMatchers
(
elementMatchers
,
setMatchers
)
);
// Save selector and tokenization
cached
.
selector
=
selector
;
}
}
return
cached
;
return
cached
;
};
};
function
multipleContexts
(
selector
,
contexts
,
results
)
{
/**
var
i
=
0
,
* A low-level selection function that works with Sizzle's compiled
len
=
contexts
.
length
;
* selector functions
for
(
;
i
<
len
;
i
++
)
{
* @param {String|Function} selector A selector or a pre-compiled
Sizzle
(
selector
,
contexts
[
i
],
results
);
* selector function built with Sizzle.compile
}
* @param {Element} context
return
results
;
* @param {Array} [results]
}
* @param {Array} [seed] A set of elements to match against
*/
function
select
(
selector
,
context
,
results
,
seed
)
{
select
=
Sizzle
.
select
=
function
(
selector
,
context
,
results
,
seed
)
{
var
i
,
tokens
,
token
,
type
,
find
,
var
i
,
tokens
,
token
,
type
,
find
,
match
=
tokenize
(
selector
);
compiled
=
typeof
selector
===
"function"
&&
selector
,
match
=
!
seed
&&
tokenize
(
(
selector
=
compiled
.
selector
||
selector
)
);
if
(
!
seed
)
{
results
=
results
||
[];
// Try to minimize operations if there is only one group
if
(
match
.
length
===
1
)
{
// Take a shortcut and set the context if the root selector is an ID
// Try to minimize operations if there is no seed and only one group
tokens
=
match
[
0
]
=
match
[
0
].
slice
(
0
);
if
(
match
.
length
===
1
)
{
if
(
tokens
.
length
>
2
&&
(
token
=
tokens
[
0
]).
type
===
"ID"
&&
support
.
getById
&&
context
.
nodeType
===
9
&&
documentIsHTML
&&
Expr
.
relative
[
tokens
[
1
].
type
]
)
{
context
=
(
Expr
.
find
[
"ID"
](
token
.
matches
[
0
].
replace
(
runescape
,
funescape
),
context
)
||
[]
)[
0
];
// Take a shortcut and set the context if the root selector is an ID
if
(
!
context
)
{
tokens
=
match
[
0
]
=
match
[
0
].
slice
(
0
);
return
results
;
if
(
tokens
.
length
>
2
&&
(
token
=
tokens
[
0
]).
type
===
"ID"
&&
}
support
.
getById
&&
context
.
nodeType
===
9
&&
documentIsHTML
&&
selector
=
selector
.
slice
(
tokens
.
shift
().
value
.
length
);
Expr
.
relative
[
tokens
[
1
].
type
]
)
{
context
=
(
Expr
.
find
[
"ID"
](
token
.
matches
[
0
].
replace
(
runescape
,
funescape
),
context
)
||
[]
)[
0
];
if
(
!
context
)
{
return
results
;
// Precompiled matchers will still verify ancestry, so step up a level
}
else
if
(
compiled
)
{
context
=
context
.
parentNode
;
}
}
// Fetch a seed set for right-to-left matching
selector
=
selector
.
slice
(
tokens
.
shift
().
value
.
length
);
i
=
matchExpr
[
"needsContext"
].
test
(
selector
)
?
0
:
tokens
.
length
;
}
while
(
i
--
)
{
token
=
tokens
[
i
];
// Abort if we hit a combinator
// Fetch a seed set for right-to-left matching
if
(
Expr
.
relative
[
(
type
=
token
.
type
)
]
)
{
i
=
matchExpr
[
"needsContext"
].
test
(
selector
)
?
0
:
tokens
.
length
;
break
;
while
(
i
--
)
{
}
token
=
tokens
[
i
];
if
(
(
find
=
Expr
.
find
[
type
])
)
{
// Search, expanding context for leading sibling combinators
if
(
(
seed
=
find
(
token
.
matches
[
0
].
replace
(
runescape
,
funescape
),
rsibling
.
test
(
tokens
[
0
].
type
)
&&
testContext
(
context
.
parentNode
)
||
context
))
)
{
// If seed is empty or no tokens remain, we can return early
tokens
.
splice
(
i
,
1
);
selector
=
seed
.
length
&&
toSelector
(
tokens
);
if
(
!
selector
)
{
push
.
apply
(
results
,
seed
);
return
results
;
}
break
;
// Abort if we hit a combinator
if
(
Expr
.
relative
[
(
type
=
token
.
type
)
]
)
{
break
;
}
if
(
(
find
=
Expr
.
find
[
type
])
)
{
// Search, expanding context for leading sibling combinators
if
(
(
seed
=
find
(
token
.
matches
[
0
].
replace
(
runescape
,
funescape
),
rsibling
.
test
(
tokens
[
0
].
type
)
&&
testContext
(
context
.
parentNode
)
||
context
))
)
{
// If seed is empty or no tokens remain, we can return early
tokens
.
splice
(
i
,
1
);
selector
=
seed
.
length
&&
toSelector
(
tokens
);
if
(
!
selector
)
{
push
.
apply
(
results
,
seed
);
return
results
;
}
}
break
;
}
}
}
}
}
}
}
}
// Compile and execute a filtering function
// Compile and execute a filtering function
if one is not provided
// Provide `match` to avoid retokenization if we modified the selector above
// Provide `match` to avoid retokenization if we modified the selector above
compile
(
selector
,
match
)(
(
compiled
||
compile
(
selector
,
match
)
)(
seed
,
seed
,
context
,
context
,
!
documentIsHTML
,
!
documentIsHTML
,
...
@@ -1936,7 +1955,7 @@ function select( selector, context, results, seed ) {
...
@@ -1936,7 +1955,7 @@ function select( selector, context, results, seed ) {
rsibling
.
test
(
selector
)
&&
testContext
(
context
.
parentNode
)
||
context
rsibling
.
test
(
selector
)
&&
testContext
(
context
.
parentNode
)
||
context
);
);
return
results
;
return
results
;
}
}
;
// One-time assignments
// One-time assignments
...
...
src/sizzle/dist/sizzle.min.js
View file @
e70d0d74
This diff is collapsed.
Click to expand it.
src/sizzle/dist/sizzle.min.map
View file @
e70d0d74
This diff is collapsed.
Click to expand it.
src/sizzle/test/unit/selector.js
View file @
e70d0d74
...
@@ -162,7 +162,7 @@ test("broken", function() {
...
@@ -162,7 +162,7 @@ test("broken", function() {
var
attrbad
,
var
attrbad
,
broken
=
function
(
name
,
selector
)
{
broken
=
function
(
name
,
selector
)
{
raise
s
(
function
()
{
throw
s
(
function
()
{
// Setting context to null here somehow avoids QUnit's window.error handling
// Setting context to null here somehow avoids QUnit's window.error handling
// making the e & e.message correct
// making the e & e.message correct
// For whatever reason, without this,
// For whatever reason, without this,
...
@@ -1055,7 +1055,7 @@ test("pseudo - :lang", function() {
...
@@ -1055,7 +1055,7 @@ test("pseudo - :lang", function() {
anchor
.
lang
=
"ara
\\
b"
;
anchor
.
lang
=
"ara
\\
b"
;
deepEqual
(
Sizzle
(
":lang(ara
\\
b)"
,
foo
),
[],
":lang respects backslashes"
);
deepEqual
(
Sizzle
(
":lang(ara
\\
b)"
,
foo
),
[],
":lang respects backslashes"
);
deepEqual
(
Sizzle
(
":lang(ara
\\\\
b)"
,
foo
),
[
anchor
],
":lang respects escaped backslashes"
);
deepEqual
(
Sizzle
(
":lang(ara
\\\\
b)"
,
foo
),
[
anchor
],
":lang respects escaped backslashes"
);
raise
s
(
function
()
{
throw
s
(
function
()
{
Sizzle
.
call
(
null
,
"dl:lang(c++)"
);
Sizzle
.
call
(
null
,
"dl:lang(c++)"
);
},
function
(
e
)
{
},
function
(
e
)
{
return
e
.
message
.
indexOf
(
"Syntax error"
)
>=
0
;
return
e
.
message
.
indexOf
(
"Syntax error"
)
>=
0
;
...
@@ -1136,3 +1136,14 @@ test("matchesSelector", function() {
...
@@ -1136,3 +1136,14 @@ test("matchesSelector", function() {
ok
(
Sizzle
.
matchesSelector
(
el
,
"* > *"
),
"child combinator (matching)"
);
ok
(
Sizzle
.
matchesSelector
(
el
,
"* > *"
),
"child combinator (matching)"
);
ok
(
!
Sizzle
.
matchesSelector
(
disconnected
,
"* > *"
),
"child combinator (not matching)"
);
ok
(
!
Sizzle
.
matchesSelector
(
disconnected
,
"* > *"
),
"child combinator (not matching)"
);
});
});
test
(
"select() with pre-compiled function"
,
function
()
{
expect
(
6
);
jQuery
.
each
([
"#qunit-fixture #first"
,
"ol#listWithTabIndex > li[tabindex]"
,
"#liveSpan1"
],
function
(
i
,
selector
)
{
var
compiled
=
Sizzle
.
compile
(
selector
);
equal
(
Sizzle
.
select
(
compiled
,
document
).
length
,
1
,
"Should match using a compiled selector function"
);
equal
(
Sizzle
.
select
(
compiled
,
Sizzle
(
"#first"
)[
0
]
).
length
,
0
,
"Should not match with different context"
);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment