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
e532dfe5
Commit
e532dfe5
authored
Jul 16, 2009
by
Yehuda Katz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for .get(-Number) Closes #4188
parent
e124fec5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
core.js
src/core.js
+2
-2
core.js
test/unit/core.js
+7
-0
No files found.
src/core.js
View file @
e532dfe5
...
...
@@ -130,10 +130,10 @@ jQuery.fn = jQuery.prototype = {
return
num
==
null
?
// Return a 'clean' array
Array
.
prototype
.
slice
.
call
(
this
)
:
this
.
toArray
(
)
:
// Return just the object
this
[
num
]
;
(
num
<
0
?
this
.
toArray
.
call
(
this
,
num
)[
0
]
:
this
[
num
]
)
;
},
// Take an array of elements and push it onto the stack
...
...
test/unit/core.js
View file @
e532dfe5
...
...
@@ -340,6 +340,13 @@ test("get(Number)", function() {
equals
(
jQuery
(
"p"
).
get
(
0
),
document
.
getElementById
(
"firstp"
),
"Get A Single Element"
);
});
test
(
"get(-Number)"
,
function
()
{
expect
(
1
);
equals
(
jQuery
(
"p"
).
get
(
-
1
),
document
.
getElementById
(
"first"
),
"Get a single element with negative index"
)
})
test
(
"add(String|Element|Array|undefined)"
,
function
()
{
expect
(
12
);
isSet
(
jQuery
(
"#sndp"
).
add
(
"#en"
).
add
(
"#sap"
).
get
(),
q
(
"sndp"
,
"en"
,
"sap"
),
"Check elements from document"
);
...
...
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