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
e38f074d
Commit
e38f074d
authored
Mar 21, 2011
by
Dan Heberden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jQuery.map to conform with style guidelines - improved size/DRY code
parent
2407690e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
15 deletions
+17
-15
core.js
src/core.js
+17
-15
No files found.
src/core.js
View file @
e38f074d
...
@@ -706,29 +706,31 @@ jQuery.extend({
...
@@ -706,29 +706,31 @@ jQuery.extend({
// arg is for internal usage only
// arg is for internal usage only
map
:
function
(
elems
,
callback
,
arg
)
{
map
:
function
(
elems
,
callback
,
arg
)
{
var
ret
=
[],
var
ret
=
[],
value
,
i
=
0
,
value
,
length
=
elems
.
length
,
length
=
elems
.
length
,
// same object detection used in jQuery.each, not full-proof but very speedy.
// same object detection used in jQuery.each, not full-proof but very speedy.
isObj
=
length
===
undefined
;
isObj
=
length
===
undefined
;
if
(
isObj
)
{
// the work for the loops - run elems[x] through callback
for
(
key
in
elems
)
{
inLoop
=
function
(
key
)
{
value
=
callback
(
elems
[
key
],
key
,
arg
);
value
=
callback
(
elems
[
key
],
key
,
arg
);
if
(
value
!=
null
)
{
if
(
value
!=
null
)
{
ret
[
ret
.
length
]
=
value
;
ret
[
ret
.
length
]
=
value
;
}
}
}
}
}
else
{
// Go through the array, translating each of the items to their
// new value (or values).
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
value
=
callback
(
elems
[
i
],
i
,
arg
);
if
(
value
!=
null
)
{
// Go thorugh every key on the object
ret
[
ret
.
length
]
=
value
;
if
(
isObj
)
{
for
(
key
in
elems
)
{
inLoop
(
key
);
}
}
// Go through the array, translating each of the items to their
// new value (or values).
}
else
{
for
(
;
i
<
length
;
i
++
)
{
inLoop
(
i
);
}
}
}
}
...
...
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