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
05d401dd
Commit
05d401dd
authored
Aug 19, 2007
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed non-unique results from .parent(), .parents(), .next(), etc. (Bug #1449)
parent
760a244d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
7 deletions
+16
-7
index.html
build/test/index.html
+1
-1
coreTest.js
src/jquery/coreTest.js
+14
-5
jquery.js
src/jquery/jquery.js
+1
-1
No files found.
build/test/index.html
View file @
05d401dd
...
...
@@ -19,7 +19,7 @@
<h2
id=
"userAgent"
></h2>
<!-- Test HTML -->
<dl
style=
"display:none;"
>
<dl
id=
"dl"
style=
"display:none;"
>
<div
id=
"main"
style=
"display: none;"
>
<p
id=
"firstp"
>
See
<a
id=
"simon1"
href=
"http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector"
rel=
"bookmark"
>
this blog entry
</a>
for more information.
</p>
<p
id=
"ap"
>
...
...
src/jquery/coreTest.js
View file @
05d401dd
...
...
@@ -722,11 +722,12 @@ test("not()", function() {
});
test
(
"siblings([String])"
,
function
()
{
expect
(
4
);
expect
(
5
);
isSet
(
$
(
"#en"
).
siblings
().
get
(),
q
(
"sndp"
,
"sap"
),
"Check for siblings"
);
isSet
(
$
(
"#sndp"
).
siblings
(
"[code]"
).
get
(),
q
(
"sap"
),
"Check for filtered siblings (has code child element)"
);
isSet
(
$
(
"#sndp"
).
siblings
(
"[a]"
).
get
(),
q
(
"en"
,
"sap"
),
"Check for filtered siblings (has anchor child element)"
);
isSet
(
$
(
"#foo"
).
siblings
(
"form, b"
).
get
(),
q
(
"form"
,
"lengthtest"
,
"floatTest"
),
"Check for multiple filters"
);
isSet
(
$
(
"#en, #sndp"
).
siblings
().
get
(),
q
(
"sndp"
,
"sap"
,
"en"
),
"Check for unique results from siblings"
);
});
test
(
"children([String])"
,
function
()
{
...
...
@@ -736,26 +737,34 @@ test("children([String])", function() {
isSet
(
$
(
"#foo"
).
children
(
"#en, #sap"
).
get
(),
q
(
"en"
,
"sap"
),
"Check for multiple filters"
);
});
test
(
"parent
[s]
([String])"
,
function
()
{
expect
(
8
);
test
(
"parent([String])"
,
function
()
{
expect
(
5
);
ok
(
$
(
"#groups"
).
parent
()[
0
].
id
==
"ap"
,
"Simple parent check"
);
ok
(
$
(
"#groups"
).
parent
(
"p"
)[
0
].
id
==
"ap"
,
"Filtered parent check"
);
ok
(
$
(
"#groups"
).
parent
(
"div"
).
length
==
0
,
"Filtered parent check, no match"
);
ok
(
$
(
"#groups"
).
parent
(
"div, p"
)[
0
].
id
==
"ap"
,
"Check for multiple filters"
);
isSet
(
$
(
"#en, #sndp"
).
parent
().
get
(),
q
(
"foo"
),
"Check for unique results from parent"
);
});
test
(
"parents([String])"
,
function
()
{
expect
(
5
);
ok
(
$
(
"#groups"
).
parents
()[
0
].
id
==
"ap"
,
"Simple parents check"
);
ok
(
$
(
"#groups"
).
parents
(
"p"
)[
0
].
id
==
"ap"
,
"Filtered parents check"
);
ok
(
$
(
"#groups"
).
parents
(
"div"
)[
0
].
id
==
"main"
,
"Filtered parents check2"
);
isSet
(
$
(
"#groups"
).
parents
(
"p, div"
).
get
(),
q
(
"ap"
,
"main"
),
"Check for multiple filters"
);
isSet
(
$
(
"#en, #sndp"
).
parents
().
get
(),
q
(
"foo"
,
"main"
,
"dl"
,
"body"
,
"html"
),
"Check for unique results from parents"
);
});
test
(
"next
/prev
([String])"
,
function
()
{
expect
(
8
);
test
(
"next([String])"
,
function
()
{
expect
(
4
);
ok
(
$
(
"#ap"
).
next
()[
0
].
id
==
"foo"
,
"Simple next check"
);
ok
(
$
(
"#ap"
).
next
(
"div"
)[
0
].
id
==
"foo"
,
"Filtered next check"
);
ok
(
$
(
"#ap"
).
next
(
"p"
).
length
==
0
,
"Filtered next check, no match"
);
ok
(
$
(
"#ap"
).
next
(
"div, p"
)[
0
].
id
==
"foo"
,
"Multiple filters"
);
});
test
(
"prev([String])"
,
function
()
{
expect
(
4
);
ok
(
$
(
"#foo"
).
prev
()[
0
].
id
==
"ap"
,
"Simple prev check"
);
ok
(
$
(
"#foo"
).
prev
(
"p"
)[
0
].
id
==
"ap"
,
"Filtered prev check"
);
ok
(
$
(
"#foo"
).
prev
(
"div"
).
length
==
0
,
"Filtered prev check, no match"
);
...
...
src/jquery/jquery.js
View file @
05d401dd
...
...
@@ -2073,7 +2073,7 @@ jQuery.each({
var
ret
=
jQuery
.
map
(
this
,
n
);
if
(
a
&&
typeof
a
==
"string"
)
ret
=
jQuery
.
multiFilter
(
a
,
ret
);
return
this
.
pushStack
(
ret
);
return
this
.
pushStack
(
jQuery
.
unique
(
ret
)
);
};
});
...
...
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