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
4ef51690
Commit
4ef51690
authored
Mar 27, 2013
by
Richard Gibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #13539: Utilize Sizzle hooks. Close gh-1215.
parent
f8b27f16
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
165 additions
and
145 deletions
+165
-145
Gruntfile.js
Gruntfile.js
+1
-1
attributes.js
src/attributes.js
+97
-97
sizzle
src/sizzle
+1
-1
sizzle-jquery.js
src/sizzle-jquery.js
+0
-2
traversing.js
src/traversing.js
+28
-30
css.js
test/unit/css.js
+2
-2
selector.js
test/unit/selector.js
+1
-8
traversing.js
test/unit/traversing.js
+35
-4
No files found.
Gruntfile.js
View file @
4ef51690
...
...
@@ -41,6 +41,7 @@ module.exports = function( grunt ) {
src
:
[
"src/intro.js"
,
"src/core.js"
,
"src/selector-sizzle.js"
,
"src/callbacks.js"
,
"src/deferred.js"
,
"src/support.js"
,
...
...
@@ -48,7 +49,6 @@ module.exports = function( grunt ) {
"src/queue.js"
,
"src/attributes.js"
,
"src/event.js"
,
"src/selector-sizzle.js"
,
"src/traversing.js"
,
"src/manipulation.js"
,
{
flag
:
"css"
,
src
:
"src/css.js"
},
...
...
src/attributes.js
View file @
4ef51690
This diff is collapsed.
Click to expand it.
sizzle
@
cf19fa8d
Subproject commit
a9ab22e770ab94c4c8b426e2f46f6ab91a19639d
Subproject commit
cf19fa8dd6b7fda254bb3434f63d590845eaa7bf
src/sizzle-jquery.js
View file @
4ef51690
// Override sizzle attribute retrieval
Sizzle
.
attr
=
jQuery
.
attr
;
jQuery
.
find
=
Sizzle
;
jQuery
.
expr
=
Sizzle
.
selectors
;
jQuery
.
expr
[
":"
]
=
jQuery
.
expr
.
pseudos
;
...
...
src/traversing.js
View file @
4ef51690
var
runtil
=
/Until$/
,
rparentsprev
=
/^
(?:
parents|prev
(?:
Until|All
))
/
,
isSimple
=
/^.
[^
:#
\[\.
,
]
*$/
,
var
isSimple
=
/^.
[^
:#
\[\.
,
]
*$/
,
rneedsContext
=
jQuery
.
expr
.
match
.
needsContext
,
// methods guaranteed to produce a unique set when starting from a unique set
guaranteedUnique
=
{
...
...
@@ -52,11 +50,11 @@ jQuery.fn.extend({
},
not
:
function
(
selector
)
{
return
this
.
pushStack
(
winnow
(
this
,
selector
,
fals
e
)
);
return
this
.
pushStack
(
winnow
(
this
,
selector
||
[],
tru
e
)
);
},
filter
:
function
(
selector
)
{
return
this
.
pushStack
(
winnow
(
this
,
selector
,
tru
e
)
);
return
this
.
pushStack
(
winnow
(
this
,
selector
||
[],
fals
e
)
);
},
is
:
function
(
selector
)
{
...
...
@@ -188,7 +186,7 @@ jQuery.each({
jQuery
.
fn
[
name
]
=
function
(
until
,
selector
)
{
var
ret
=
jQuery
.
map
(
this
,
fn
,
until
);
if
(
!
runtil
.
test
(
name
)
)
{
if
(
name
.
slice
(
-
5
)
!==
"Until"
)
{
selector
=
until
;
}
...
...
@@ -196,10 +194,16 @@ jQuery.each({
ret
=
jQuery
.
filter
(
selector
,
ret
);
}
ret
=
this
.
length
>
1
&&
!
guaranteedUnique
[
name
]
?
jQuery
.
unique
(
ret
)
:
ret
;
if
(
this
.
length
>
1
)
{
// Remove duplicates
if
(
!
guaranteedUnique
[
name
]
)
{
ret
=
jQuery
.
unique
(
ret
);
}
if
(
this
.
length
>
1
&&
rparentsprev
.
test
(
name
)
)
{
ret
=
ret
.
reverse
();
// Reverse order for parents* and prev*
if
(
name
.
charAt
(
0
)
===
"p"
)
{
ret
=
ret
.
reverse
();
}
}
return
this
.
pushStack
(
ret
);
...
...
@@ -208,13 +212,17 @@ jQuery.each({
jQuery
.
extend
({
filter
:
function
(
expr
,
elems
,
not
)
{
var
elem
=
elems
[
0
];
if
(
not
)
{
expr
=
":not("
+
expr
+
")"
;
}
return
elems
.
length
===
1
?
jQuery
.
find
.
matchesSelector
(
elems
[
0
],
expr
)
?
[
elems
[
0
]
]
:
[]
:
jQuery
.
find
.
matches
(
expr
,
elems
);
return
elems
.
length
===
1
&&
elem
.
nodeType
===
1
?
jQuery
.
find
.
matchesSelector
(
elem
,
expr
)
?
[
elem
]
:
[]
:
jQuery
.
find
.
matches
(
expr
,
jQuery
.
grep
(
elems
,
function
(
elem
)
{
return
elem
.
nodeType
===
1
;
}));
},
dir
:
function
(
elem
,
dir
,
until
)
{
...
...
@@ -244,36 +252,26 @@ jQuery.extend({
});
// Implement the identical functionality for filter and not
function
winnow
(
elements
,
qualifier
,
keep
)
{
// Can't pass null or undefined to indexOf
// Set to 0 to skip string check
qualifier
=
qualifier
||
0
;
function
winnow
(
elements
,
qualifier
,
not
)
{
if
(
jQuery
.
isFunction
(
qualifier
)
)
{
return
jQuery
.
grep
(
elements
,
function
(
elem
,
i
)
{
var
retVal
=
!!
qualifier
.
call
(
elem
,
i
,
elem
);
return
retVal
===
keep
;
return
jQuery
.
grep
(
elements
,
function
(
elem
,
i
)
{
return
qualifier
.
call
(
elem
,
i
,
elem
)
?
!
not
:
not
;
});
}
else
if
(
qualifier
.
nodeType
)
{
return
jQuery
.
grep
(
elements
,
function
(
elem
)
{
return
(
elem
===
qualifier
)
===
keep
;
return
jQuery
.
grep
(
elements
,
function
(
elem
)
{
return
(
elem
===
qualifier
)
!==
not
;
});
}
else
if
(
typeof
qualifier
===
"string"
)
{
var
filtered
=
jQuery
.
grep
(
elements
,
function
(
elem
)
{
return
elem
.
nodeType
===
1
;
});
if
(
isSimple
.
test
(
qualifier
)
)
{
return
jQuery
.
filter
(
qualifier
,
filtered
,
!
keep
);
return
jQuery
.
filter
(
qualifier
,
elements
,
not
);
}
else
{
qualifier
=
jQuery
.
filter
(
qualifier
,
filtered
);
qualifier
=
jQuery
.
filter
(
qualifier
,
elements
);
}
}
return
jQuery
.
grep
(
elements
,
function
(
elem
)
{
return
(
jQuery
.
inArray
(
elem
,
qualifier
)
>=
0
)
===
keep
;
return
(
jQuery
.
inArray
(
elem
,
qualifier
)
>=
0
)
!==
not
;
});
}
test/unit/css.js
View file @
4ef51690
...
...
@@ -904,8 +904,8 @@ test( ":visible/:hidden selectors", function() {
ok
(
!
jQuery
(
"#nothiddendiv"
).
is
(
":visible"
),
"Modified CSS display: Assert element is hidden"
);
jQuery
(
"#nothiddendiv"
).
css
({
"display"
:
"block"
});
ok
(
jQuery
(
"#nothiddendiv"
).
is
(
":visible"
),
"Modified CSS display: Assert element is visible"
);
ok
(
jQuery
(
window
).
is
(
":visible"
)
,
"Calling is(':visible') on window does not throw an error in IE.
"
);
ok
(
jQuery
(
document
).
is
(
":visible"
)
,
"Calling is(':visible') on document does not throw an error in IE.
"
);
ok
(
jQuery
(
window
).
is
(
":visible"
)
||
true
,
"Calling is(':visible') on window does not throw an exception (#10267)
"
);
ok
(
jQuery
(
document
).
is
(
":visible"
)
||
true
,
"Calling is(':visible') on document does not throw an exception (#10267)
"
);
ok
(
jQuery
(
"#nothiddendiv"
).
is
(
":visible"
),
"Modifying CSS display: Assert element is visible"
);
jQuery
(
"#nothiddendiv"
).
css
(
"display"
,
"none"
);
...
...
test/unit/selector.js
View file @
4ef51690
...
...
@@ -31,17 +31,10 @@ test("class - jQuery only", function() {
});
test
(
"attributes - jQuery only"
,
function
()
{
expect
(
6
);
expect
(
5
);
t
(
"Find elements with a tabindex attribute"
,
"[tabindex]"
,
[
"listWithTabIndex"
,
"foodWithNegativeTabIndex"
,
"linkWithTabIndex"
,
"linkWithNegativeTabIndex"
,
"linkWithNoHrefWithTabIndex"
,
"linkWithNoHrefWithNegativeTabIndex"
]
);
// #12523
deepEqual
(
jQuery
.
find
(
"[title]"
,
null
,
null
,
jQuery
(
"#qunit-fixture a"
).
get
().
concat
(
document
.
createTextNode
(
""
)
)
),
q
(
"google"
),
"Text nodes fail attribute tests without exception"
);
// #12600
ok
(
jQuery
(
"<select value='12600'><option value='option' selected='selected'></option><option value=''></option></select>"
)
...
...
test/unit/traversing.js
View file @
4ef51690
...
...
@@ -78,10 +78,29 @@ test("is(String|undefined)", function() {
ok
(
jQuery
(
"#en"
).
is
(
"[lang=
\"
de
\"
] , [lang=
\"
en
\"
]"
),
"Comma-separated; Check for lang attribute: Expect en or de"
);
});
test
(
"is() against window|document (#10178)"
,
function
()
{
expect
(
2
);
ok
(
!
jQuery
(
window
).
is
(
"a"
),
"Checking is on a window does not throw an exception"
);
ok
(
!
jQuery
(
document
).
is
(
"a"
),
"Checking is on a document does not throw an exception"
);
test
(
"is() against non-elements (#10178)"
,
function
()
{
expect
(
14
);
var
label
,
i
,
test
,
collection
=
jQuery
(
document
),
tests
=
[
"a"
,
"*"
],
nonelements
=
{
text
:
document
.
createTextNode
(
""
),
comment
:
document
.
createComment
(
""
),
document
:
document
,
window
:
window
,
array
:
[],
"plain object"
:
{},
"function"
:
function
()
{}
};
for
(
label
in
nonelements
)
{
collection
[
0
]
=
nonelements
[
label
];
for
(
i
=
0
;
i
<
tests
.
length
;
i
++
)
{
test
=
tests
[
i
];
ok
(
!
collection
.
is
(
test
),
label
+
" does not match
\"
"
+
test
+
"
\"
"
);
}
}
});
test
(
"is(jQuery)"
,
function
()
{
...
...
@@ -711,3 +730,15 @@ test("index(no arg) #10977", function() {
strictEqual
(
jQuery
(
"#indextest li.zero"
).
first
().
index
()
,
0
,
"No Argument Index Check"
);
$list
.
remove
();
});
test
(
"traversing non-elements with attribute filters (#12523)"
,
function
()
{
expect
(
5
);
var
nonnodes
=
jQuery
(
"#nonnodes"
).
contents
();
equal
(
nonnodes
.
filter
(
"[id]"
).
length
,
1
,
".filter"
);
equal
(
nonnodes
.
find
(
"[id]"
).
length
,
0
,
".find"
);
strictEqual
(
nonnodes
.
is
(
"[id]"
),
true
,
".is"
);
deepEqual
(
nonnodes
.
closest
(
"[id='nonnodes']"
).
get
(),
q
(
"nonnodes"
),
".closest"
);
deepEqual
(
nonnodes
.
parents
(
"[id='nonnodes']"
).
get
(),
q
(
"nonnodes"
),
".parents"
);
});
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