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
391c21b1
Commit
391c21b1
authored
Jan 17, 2014
by
Richard Gibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Traversing: Check all pairwise element combinations for .find( els )
Ref
b8d0d54a
Fixes #14701
parent
a2250b0f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
+7
-6
findFilter.js
src/traversing/findFilter.js
+3
-4
traversing.js
test/unit/traversing.js
+4
-2
No files found.
src/traversing/findFilter.js
View file @
391c21b1
...
@@ -53,14 +53,14 @@ jQuery.filter = function( expr, elems, not ) {
...
@@ -53,14 +53,14 @@ jQuery.filter = function( expr, elems, not ) {
jQuery
.
fn
.
extend
({
jQuery
.
fn
.
extend
({
find
:
function
(
selector
)
{
find
:
function
(
selector
)
{
var
i
=
0
,
var
i
,
len
=
this
.
length
,
len
=
this
.
length
,
ret
=
[],
ret
=
[],
self
=
this
;
self
=
this
;
if
(
typeof
selector
!==
"string"
)
{
if
(
typeof
selector
!==
"string"
)
{
return
this
.
pushStack
(
jQuery
(
selector
).
filter
(
function
()
{
return
this
.
pushStack
(
jQuery
(
selector
).
filter
(
function
()
{
for
(
;
i
<
len
;
i
++
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
(
jQuery
.
contains
(
self
[
i
],
this
)
)
{
if
(
jQuery
.
contains
(
self
[
i
],
this
)
)
{
return
true
;
return
true
;
}
}
...
@@ -68,8 +68,7 @@ jQuery.fn.extend({
...
@@ -68,8 +68,7 @@ jQuery.fn.extend({
})
);
})
);
}
}
i
=
0
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
for
(
;
i
<
len
;
i
++
)
{
jQuery
.
find
(
selector
,
self
[
i
],
ret
);
jQuery
.
find
(
selector
,
self
[
i
],
ret
);
}
}
...
...
test/unit/traversing.js
View file @
391c21b1
...
@@ -24,19 +24,21 @@ test( "find(leading combinator)", function() {
...
@@ -24,19 +24,21 @@ test( "find(leading combinator)", function() {
});
});
test
(
"find(node|jQuery object)"
,
function
()
{
test
(
"find(node|jQuery object)"
,
function
()
{
expect
(
1
2
);
expect
(
1
3
);
var
$foo
=
jQuery
(
"#foo"
),
var
$foo
=
jQuery
(
"#foo"
),
$blog
=
jQuery
(
".blogTest"
),
$blog
=
jQuery
(
".blogTest"
),
$first
=
jQuery
(
"#first"
),
$first
=
jQuery
(
"#first"
),
$two
=
$blog
.
add
(
$first
),
$two
=
$blog
.
add
(
$first
),
$twoMore
=
jQuery
(
"#ap"
).
add
(
$blog
),
$fooTwo
=
$foo
.
add
(
$blog
);
$fooTwo
=
$foo
.
add
(
$blog
);
equal
(
$foo
.
find
(
$blog
).
text
(),
"Yahoo"
,
"Find with blog jQuery object"
);
equal
(
$foo
.
find
(
$blog
).
text
(),
"Yahoo"
,
"Find with blog jQuery object"
);
equal
(
$foo
.
find
(
$blog
[
0
]
).
text
(),
"Yahoo"
,
"Find with blog node"
);
equal
(
$foo
.
find
(
$blog
[
0
]
).
text
(),
"Yahoo"
,
"Find with blog node"
);
equal
(
$foo
.
find
(
$first
).
length
,
0
,
"#first is not in #foo"
);
equal
(
$foo
.
find
(
$first
).
length
,
0
,
"#first is not in #foo"
);
equal
(
$foo
.
find
(
$first
[
0
]).
length
,
0
,
"#first not in #foo (node)"
);
equal
(
$foo
.
find
(
$first
[
0
]).
length
,
0
,
"#first not in #foo (node)"
);
ok
(
$foo
.
find
(
$two
).
is
(
".blogTest"
),
"Find returns only nodes within #foo"
);
deepEqual
(
$foo
.
find
(
$two
).
get
(),
$blog
.
get
(),
"Find returns only nodes within #foo"
);
deepEqual
(
$foo
.
find
(
$twoMore
).
get
(),
$blog
.
get
(),
"...regardless of order"
);
ok
(
$fooTwo
.
find
(
$blog
).
is
(
".blogTest"
),
"Blog is part of the collection, but also within foo"
);
ok
(
$fooTwo
.
find
(
$blog
).
is
(
".blogTest"
),
"Blog is part of the collection, but also within foo"
);
ok
(
$fooTwo
.
find
(
$blog
[
0
]
).
is
(
".blogTest"
),
"Blog is part of the collection, but also within foo(node)"
);
ok
(
$fooTwo
.
find
(
$blog
[
0
]
).
is
(
".blogTest"
),
"Blog is part of the collection, but also within foo(node)"
);
...
...
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