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
5c0b5d25
Commit
5c0b5d25
authored
Nov 19, 2010
by
Anton M
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve performance of get() for negative indices. Fixes #5476.
parent
0838bdf5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
core.js
src/core.js
+1
-1
core.js
test/unit/core.js
+5
-5
No files found.
src/core.js
View file @
5c0b5d25
...
@@ -215,7 +215,7 @@ jQuery.fn = jQuery.prototype = {
...
@@ -215,7 +215,7 @@ jQuery.fn = jQuery.prototype = {
this
.
toArray
()
:
this
.
toArray
()
:
// Return just the object
// Return just the object
(
num
<
0
?
this
.
slice
(
num
)[
0
]
:
this
[
num
]
);
(
num
<
0
?
this
[
this
.
length
+
num
]
:
this
[
num
]
);
},
},
// Take an array of elements and push it onto the stack
// Take an array of elements and push it onto the stack
...
...
test/unit/core.js
View file @
5c0b5d25
...
@@ -547,15 +547,15 @@ test("toArray()", function() {
...
@@ -547,15 +547,15 @@ test("toArray()", function() {
})
})
test
(
"get(Number)"
,
function
()
{
test
(
"get(Number)"
,
function
()
{
expect
(
1
);
expect
(
2
);
equals
(
jQuery
(
"p"
).
get
(
0
),
document
.
getElementById
(
"firstp"
),
"Get A Single Element"
);
equals
(
jQuery
(
"p"
).
get
(
0
),
document
.
getElementById
(
"firstp"
),
"Get A Single Element"
);
strictEqual
(
jQuery
(
"#firstp"
).
get
(
1
),
undefined
,
"Try get with index larger elements count"
);
});
});
test
(
"get(-Number)"
,
function
()
{
test
(
"get(-Number)"
,
function
()
{
expect
(
1
);
expect
(
2
);
equals
(
jQuery
(
"p"
).
get
(
-
1
),
equals
(
jQuery
(
"p"
).
get
(
-
1
),
document
.
getElementById
(
"first"
),
"Get a single element with negative index"
);
document
.
getElementById
(
"first"
),
strictEqual
(
jQuery
(
"#firstp"
).
get
(
-
2
),
undefined
,
"Try get with index negative index larger then elements count"
);
"Get a single element with negative index"
)
})
})
test
(
"each(Function)"
,
function
()
{
test
(
"each(Function)"
,
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