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
079d651e
Commit
079d651e
authored
Aug 31, 2007
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added $(...).map() functionality. (Also closes #1250, imo)
parent
5c19701a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
coreTest.js
src/jquery/coreTest.js
+20
-0
jquery.js
src/jquery/jquery.js
+6
-0
No files found.
src/jquery/coreTest.js
View file @
079d651e
...
@@ -976,3 +976,23 @@ test("slice()", function() {
...
@@ -976,3 +976,23 @@ test("slice()", function() {
isSet
(
$
(
"#ap a"
).
slice
(
0
,
3
),
q
(
"google"
,
"groups"
,
"anchor1"
),
"slice(0,3)"
);
isSet
(
$
(
"#ap a"
).
slice
(
0
,
3
),
q
(
"google"
,
"groups"
,
"anchor1"
),
"slice(0,3)"
);
isSet
(
$
(
"#ap a"
).
slice
(
-
1
),
q
(
"mark"
),
"slice(-1)"
);
isSet
(
$
(
"#ap a"
).
slice
(
-
1
),
q
(
"mark"
),
"slice(-1)"
);
});
});
test
(
"map()"
,
function
()
{
expect
(
2
);
isSet
(
$
(
"#ap"
).
map
(
function
(){
return
$
(
this
).
find
(
"a"
).
get
();
}),
q
(
"google"
,
"groups"
,
"anchor1"
,
"mark"
),
"Array Map"
);
isSet
(
$
(
"#ap > a"
).
map
(
function
(){
return
this
.
parentNode
;
}),
q
(
"ap"
,
"ap"
,
"ap"
),
"Single Map"
);
});
src/jquery/jquery.js
View file @
079d651e
...
@@ -1189,6 +1189,12 @@ jQuery.fn = jQuery.prototype = {
...
@@ -1189,6 +1189,12 @@ jQuery.fn = jQuery.prototype = {
slice
:
function
()
{
slice
:
function
()
{
return
this
.
pushStack
(
Array
.
prototype
.
slice
.
apply
(
this
,
arguments
)
);
return
this
.
pushStack
(
Array
.
prototype
.
slice
.
apply
(
this
,
arguments
)
);
},
},
map
:
function
(
fn
){
return
this
.
pushStack
(
jQuery
.
map
(
this
,
function
(
elem
,
i
){
return
fn
.
call
(
elem
,
i
,
elem
);
}));
},
/**
/**
* @private
* @private
...
...
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