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
590bcab2
Commit
590bcab2
authored
Apr 02, 2012
by
Richard Gibson
Committed by
Dave Methvin
Apr 06, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #11543: .has should work on detached elements.
parent
c04bfce5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
traversing.js
src/traversing.js
+1
-1
traversing.js
test/unit/traversing.js
+12
-3
No files found.
src/traversing.js
View file @
590bcab2
...
...
@@ -54,7 +54,7 @@ jQuery.fn.extend({
},
has
:
function
(
target
)
{
var
targets
=
jQuery
(
target
);
var
targets
=
jQuery
(
target
,
this
);
return
this
.
filter
(
function
()
{
for
(
var
i
=
0
,
l
=
targets
.
length
;
i
<
l
;
i
++
)
{
if
(
jQuery
.
contains
(
this
,
targets
[
i
]
)
)
{
...
...
test/unit/traversing.js
View file @
590bcab2
...
...
@@ -370,21 +370,27 @@ test("not(jQuery)", function() {
});
test
(
"has(Element)"
,
function
()
{
expect
(
2
);
expect
(
3
);
var
obj
=
jQuery
(
"#qunit-fixture"
).
has
(
jQuery
(
"#sndp"
)[
0
]);
deepEqual
(
obj
.
get
(),
q
(
"qunit-fixture"
),
"Keeps elements that have the element as a descendant"
);
var
detached
=
jQuery
(
"<a><b><i/></b></a>"
);
deepEqual
(
detached
.
has
(
detached
.
find
(
"i"
)[
0
]
).
get
(),
detached
.
get
(),
"...Even when detached"
);
var
multipleParent
=
jQuery
(
"#qunit-fixture, #header"
).
has
(
jQuery
(
"#sndp"
)[
0
]);
deepEqual
(
obj
.
get
(),
q
(
"qunit-fixture"
),
"Does not include elements that do not have the element as a descendant"
);
});
test
(
"has(Selector)"
,
function
()
{
expect
(
3
);
expect
(
4
);
var
obj
=
jQuery
(
"#qunit-fixture"
).
has
(
"#sndp"
);
deepEqual
(
obj
.
get
(),
q
(
"qunit-fixture"
),
"Keeps elements that have any element matching the selector as a descendant"
);
var
detached
=
jQuery
(
"<a><b><i/></b></a>"
);
deepEqual
(
detached
.
has
(
"i"
).
get
(),
detached
.
get
(),
"...Even when detached"
);
var
multipleParent
=
jQuery
(
"#qunit-fixture, #header"
).
has
(
"#sndp"
);
deepEqual
(
obj
.
get
(),
q
(
"qunit-fixture"
),
"Does not include elements that do not have the element as a descendant"
);
...
...
@@ -393,11 +399,14 @@ test("has(Selector)", function() {
});
test
(
"has(Arrayish)"
,
function
()
{
expect
(
3
);
expect
(
4
);
var
simple
=
jQuery
(
"#qunit-fixture"
).
has
(
jQuery
(
"#sndp"
));
deepEqual
(
simple
.
get
(),
q
(
"qunit-fixture"
),
"Keeps elements that have any element in the jQuery list as a descendant"
);
var
detached
=
jQuery
(
"<a><b><i/></b></a>"
);
deepEqual
(
detached
.
has
(
detached
.
find
(
"i"
)
).
get
(),
detached
.
get
(),
"...Even when detached"
);
var
multipleParent
=
jQuery
(
"#qunit-fixture, #header"
).
has
(
jQuery
(
"#sndp"
));
deepEqual
(
multipleParent
.
get
(),
q
(
"qunit-fixture"
),
"Does not include elements that do not have an element in the jQuery list as a descendant"
);
...
...
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