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
b5084b4b
Commit
b5084b4b
authored
Oct 19, 2012
by
Richard Gibson
Committed by
Dave Methvin
Oct 20, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #4262: faster .eq(), closes gh-1000.
parent
32051e97
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
48 deletions
+16
-48
core.js
src/core.js
+7
-8
core.js
test/unit/core.js
+9
-40
No files found.
src/core.js
View file @
b5084b4b
...
@@ -234,11 +234,9 @@ jQuery.fn = jQuery.prototype = {
...
@@ -234,11 +234,9 @@ jQuery.fn = jQuery.prototype = {
return
this
;
return
this
;
},
},
eq
:
function
(
i
)
{
slice
:
function
()
{
i
=
+
i
;
return
this
.
pushStack
(
core_slice
.
apply
(
this
,
arguments
),
return
i
===
-
1
?
"slice"
,
core_slice
.
call
(
arguments
).
join
(
","
)
);
this
.
slice
(
i
)
:
this
.
slice
(
i
,
i
+
1
);
},
},
first
:
function
()
{
first
:
function
()
{
...
@@ -249,9 +247,10 @@ jQuery.fn = jQuery.prototype = {
...
@@ -249,9 +247,10 @@ jQuery.fn = jQuery.prototype = {
return
this
.
eq
(
-
1
);
return
this
.
eq
(
-
1
);
},
},
slice
:
function
()
{
eq
:
function
(
i
)
{
return
this
.
pushStack
(
core_slice
.
apply
(
this
,
arguments
),
var
len
=
this
.
length
,
"slice"
,
core_slice
.
call
(
arguments
).
join
(
","
)
);
j
=
+
i
+
(
i
<
0
?
len
:
0
);
return
this
.
pushStack
(
j
>=
0
&&
j
<
len
?
[
this
[
j
]
]
:
[]
);
},
},
map
:
function
(
callback
)
{
map
:
function
(
callback
)
{
...
...
test/unit/core.js
View file @
b5084b4b
...
@@ -150,20 +150,20 @@ test("jQuery()", function() {
...
@@ -150,20 +150,20 @@ test("jQuery()", function() {
equal
(
jQuery
(
" a<div>"
+
lng
+
"</div>b "
).
length
,
1
,
"Make sure whitespace and other characters are trimmed on long strings."
);
equal
(
jQuery
(
" a<div>"
+
lng
+
"</div>b "
).
length
,
1
,
"Make sure whitespace and other characters are trimmed on long strings."
);
});
});
test
(
"selector state"
,
function
()
{
test
(
"selector state"
,
function
()
{
expect
(
31
);
expect
(
18
);
var
test
;
var
test
;
test
=
jQuery
(
undefined
);
test
=
jQuery
(
undefined
);
equal
(
test
.
selector
,
""
,
"Empty jQuery Selector"
);
equal
(
test
.
selector
,
""
,
"Empty jQuery Selector"
);
equal
(
test
.
context
,
undefined
,
"Empty jQuery Context"
);
equal
(
test
.
context
,
undefined
,
"Empty jQuery Context"
);
test
=
jQuery
(
document
);
test
=
jQuery
(
document
);
equal
(
test
.
selector
,
""
,
"Document Selector"
);
equal
(
test
.
selector
,
""
,
"Document Selector"
);
equal
(
test
.
context
,
document
,
"Document Context"
);
equal
(
test
.
context
,
document
,
"Document Context"
);
test
=
jQuery
(
document
.
body
);
test
=
jQuery
(
document
.
body
);
equal
(
test
.
selector
,
""
,
"Body Selector"
);
equal
(
test
.
selector
,
""
,
"Body Selector"
);
equal
(
test
.
context
,
document
.
body
,
"Body Context"
);
equal
(
test
.
context
,
document
.
body
,
"Body Context"
);
...
@@ -175,53 +175,22 @@ test("selector state", function() {
...
@@ -175,53 +175,22 @@ test("selector state", function() {
equal
(
test
.
selector
,
"#notfoundnono"
,
"#notfoundnono Selector"
);
equal
(
test
.
selector
,
"#notfoundnono"
,
"#notfoundnono Selector"
);
equal
(
test
.
context
,
document
,
"#notfoundnono Context"
);
equal
(
test
.
context
,
document
,
"#notfoundnono Context"
);
test
=
jQuery
(
"#qunit-fixture"
,
document
);
test
=
jQuery
(
"#qunit-fixture"
,
document
);
equal
(
test
.
selector
,
"#qunit-fixture"
,
"#qunit-fixture Selector"
);
equal
(
test
.
selector
,
"#qunit-fixture"
,
"#qunit-fixture Selector"
);
equal
(
test
.
context
,
document
,
"#qunit-fixture Context"
);
equal
(
test
.
context
,
document
,
"#qunit-fixture Context"
);
test
=
jQuery
(
"#qunit-fixture"
,
document
.
body
);
test
=
jQuery
(
"#qunit-fixture"
,
document
.
body
);
equal
(
test
.
selector
,
"#qunit-fixture"
,
"#qunit-fixture Selector"
);
equal
(
test
.
selector
,
"#qunit-fixture"
,
"#qunit-fixture Selector"
);
equal
(
test
.
context
,
document
.
body
,
"#qunit-fixture Context"
);
equal
(
test
.
context
,
document
.
body
,
"#qunit-fixture Context"
);
// Test cloning
// Test cloning
test
=
jQuery
(
test
);
test
=
jQuery
(
test
);
equal
(
test
.
selector
,
"#qunit-fixture"
,
"#qunit-fixture Selector"
);
equal
(
test
.
selector
,
"#qunit-fixture"
,
"#qunit-fixture Selector"
);
equal
(
test
.
context
,
document
.
body
,
"#qunit-fixture Context"
);
equal
(
test
.
context
,
document
.
body
,
"#qunit-fixture Context"
);
test
=
jQuery
(
document
.
body
).
find
(
"#qunit-fixture"
);
test
=
jQuery
(
document
.
body
).
find
(
"#qunit-fixture"
);
equal
(
test
.
selector
,
"#qunit-fixture"
,
"#qunit-fixture find Selector"
);
equal
(
test
.
selector
,
"#qunit-fixture"
,
"#qunit-fixture find Selector"
);
equal
(
test
.
context
,
document
.
body
,
"#qunit-fixture find Context"
);
equal
(
test
.
context
,
document
.
body
,
"#qunit-fixture find Context"
);
test
=
jQuery
(
"#qunit-fixture"
).
filter
(
"div"
);
equal
(
test
.
selector
,
"#qunit-fixture.filter(div)"
,
"#qunit-fixture filter Selector"
);
equal
(
test
.
context
,
document
,
"#qunit-fixture filter Context"
);
test
=
jQuery
(
"#qunit-fixture"
).
not
(
"div"
);
equal
(
test
.
selector
,
"#qunit-fixture.not(div)"
,
"#qunit-fixture not Selector"
);
equal
(
test
.
context
,
document
,
"#qunit-fixture not Context"
);
test
=
jQuery
(
"#qunit-fixture"
).
filter
(
"div"
).
not
(
"div"
);
equal
(
test
.
selector
,
"#qunit-fixture.filter(div).not(div)"
,
"#qunit-fixture filter, not Selector"
);
equal
(
test
.
context
,
document
,
"#qunit-fixture filter, not Context"
);
test
=
jQuery
(
"#qunit-fixture"
).
filter
(
"div"
).
not
(
"div"
).
end
();
equal
(
test
.
selector
,
"#qunit-fixture.filter(div)"
,
"#qunit-fixture filter, not, end Selector"
);
equal
(
test
.
context
,
document
,
"#qunit-fixture filter, not, end Context"
);
test
=
jQuery
(
"#qunit-fixture"
).
parent
(
"body"
);
equal
(
test
.
selector
,
"#qunit-fixture.parent(body)"
,
"#qunit-fixture parent Selector"
);
equal
(
test
.
context
,
document
,
"#qunit-fixture parent Context"
);
test
=
jQuery
(
"#qunit-fixture"
).
eq
(
0
);
equal
(
test
.
selector
,
"#qunit-fixture.slice(0,1)"
,
"#qunit-fixture eq Selector"
);
equal
(
test
.
context
,
document
,
"#qunit-fixture eq Context"
);
var
d
=
"<div />"
;
equal
(
jQuery
(
d
).
appendTo
(
jQuery
(
d
)).
selector
,
jQuery
(
d
).
appendTo
(
d
).
selector
,
"manipulation methods make same selector for jQuery objects"
);
});
});
test
(
"globalEval"
,
function
()
{
test
(
"globalEval"
,
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