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
fb1731ab
Commit
fb1731ab
authored
Apr 20, 2013
by
Richard Gibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #13797: .is with single-node context
(cherry picked from commit
4f786ba4
)
parent
d754b50c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
17 deletions
+28
-17
traversing.js
src/traversing.js
+10
-8
traversing.js
test/unit/traversing.js
+18
-9
No files found.
src/traversing.js
View file @
fb1731ab
...
@@ -58,14 +58,16 @@ jQuery.fn.extend({
...
@@ -58,14 +58,16 @@ jQuery.fn.extend({
},
},
is
:
function
(
selector
)
{
is
:
function
(
selector
)
{
return
!!
selector
&&
(
return
!!
winnow
(
typeof
selector
===
"string"
?
this
,
// If this is a positional/relative selector, check membership in the returned set
// so $("p:first").is("p:last") won't return true for a doc with two "p".
// If this is a positional/relative selector, check membership in the returned set
rneedsContext
.
test
(
selector
)
?
// so $("p:first").is("p:last") won't return true for a doc with two "p".
jQuery
(
selector
,
this
.
context
).
index
(
this
[
0
]
)
>=
0
:
typeof
selector
===
"string"
&&
rneedsContext
.
test
(
selector
)
?
jQuery
.
filter
(
selector
,
this
).
length
>
0
:
jQuery
(
selector
)
:
this
.
filter
(
selector
).
length
>
0
);
selector
||
[],
false
).
length
;
},
},
closest
:
function
(
selectors
,
context
)
{
closest
:
function
(
selectors
,
context
)
{
...
...
test/unit/traversing.js
View file @
fb1731ab
...
@@ -141,16 +141,22 @@ test("is() with :has() selectors", function() {
...
@@ -141,16 +141,22 @@ test("is() with :has() selectors", function() {
});
});
test
(
"is() with positional selectors"
,
function
()
{
test
(
"is() with positional selectors"
,
function
()
{
expect
(
24
);
expect
(
27
);
var
isit
=
function
(
sel
,
match
,
expect
)
{
var
equal
(
jQuery
(
sel
).
is
(
match
),
expect
,
"jQuery('"
+
sel
+
"').is('"
+
match
+
"')"
);
posp
=
jQuery
(
};
"<p id='posp'><a class='firsta' href='#'><em>first</em></a>"
+
"<a class='seconda' href='#'><b>test</b></a><em></em></p>"
jQuery
(
).
appendTo
(
"#qunit-fixture"
),
"<p id='posp'><a class='firsta' href='#'><em>first</em></a><a class='seconda' href='#'><b>test</b></a><em></em></p>"
isit
=
function
(
sel
,
match
,
expect
)
{
).
appendTo
(
"#qunit-fixture"
);
equal
(
jQuery
(
sel
).
is
(
match
),
expect
,
"jQuery('"
+
sel
+
"').is('"
+
match
+
"')"
);
};
isit
(
"#posp"
,
"p:last"
,
true
);
isit
(
"#posp"
,
"#posp:first"
,
true
);
isit
(
"#posp"
,
"#posp:first"
,
true
);
isit
(
"#posp"
,
"#posp:eq(2)"
,
false
);
isit
(
"#posp"
,
"#posp:eq(2)"
,
false
);
isit
(
"#posp"
,
"#posp a:first"
,
false
);
isit
(
"#posp"
,
"#posp a:first"
,
false
);
...
@@ -179,6 +185,9 @@ test("is() with positional selectors", function() {
...
@@ -179,6 +185,9 @@ test("is() with positional selectors", function() {
isit
(
"#posp em"
,
"#posp a em:eq(2)"
,
false
);
isit
(
"#posp em"
,
"#posp a em:eq(2)"
,
false
);
ok
(
jQuery
(
"#option1b"
).
is
(
"#select1 option:not(:first)"
),
"POS inside of :not() (#10970)"
);
ok
(
jQuery
(
"#option1b"
).
is
(
"#select1 option:not(:first)"
),
"POS inside of :not() (#10970)"
);
ok
(
jQuery
(
posp
[
0
]
).
is
(
"p:last"
),
"context constructed from a single node (#13797)"
);
ok
(
!
jQuery
(
posp
[
0
]
).
find
(
"#firsta"
).
is
(
"a:first"
),
"context derived from a single node (#13797)"
);
});
});
test
(
"index()"
,
function
()
{
test
(
"index()"
,
function
()
{
...
...
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