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
7d7a9600
Commit
7d7a9600
authored
Jul 12, 2009
by
Yehuda Katz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for .foo(Function) and testing. TODO: More tests
parent
e8eff25f
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
171 additions
and
79 deletions
+171
-79
attributes.js
src/attributes.js
+15
-5
manipulation.js
src/manipulation.js
+8
-0
manipulation.js
test/unit/manipulation.js
+148
-74
No files found.
src/attributes.js
View file @
7d7a9600
...
@@ -82,19 +82,29 @@ jQuery.fn.extend({
...
@@ -82,19 +82,29 @@ jQuery.fn.extend({
return
undefined
;
return
undefined
;
}
}
// Typecast once if the value is a number
if
(
typeof
value
===
"number"
)
if
(
typeof
value
===
"number"
)
value
+=
''
;
value
+=
''
;
var
val
=
value
;
return
this
.
each
(
function
(){
return
this
.
each
(
function
(){
if
(
jQuery
.
isFunction
(
value
))
{
val
=
value
.
call
(
this
);
// Typecast each time if the value is a Function and the appended
// value is therefore different each time.
if
(
typeof
val
===
"number"
)
val
+=
''
;
}
if
(
this
.
nodeType
!=
1
)
if
(
this
.
nodeType
!=
1
)
return
;
return
;
if
(
jQuery
.
isArray
(
val
ue
)
&&
/radio|checkbox/
.
test
(
this
.
type
)
)
if
(
jQuery
.
isArray
(
val
)
&&
/radio|checkbox/
.
test
(
this
.
type
)
)
this
.
checked
=
(
jQuery
.
inArray
(
this
.
value
,
val
ue
)
>=
0
||
this
.
checked
=
(
jQuery
.
inArray
(
this
.
value
,
val
)
>=
0
||
jQuery
.
inArray
(
this
.
name
,
val
ue
)
>=
0
);
jQuery
.
inArray
(
this
.
name
,
val
)
>=
0
);
else
if
(
jQuery
.
nodeName
(
this
,
"select"
)
)
{
else
if
(
jQuery
.
nodeName
(
this
,
"select"
)
)
{
var
values
=
jQuery
.
makeArray
(
val
ue
);
var
values
=
jQuery
.
makeArray
(
val
);
jQuery
(
"option"
,
this
).
each
(
function
(){
jQuery
(
"option"
,
this
).
each
(
function
(){
this
.
selected
=
(
jQuery
.
inArray
(
this
.
value
,
values
)
>=
0
||
this
.
selected
=
(
jQuery
.
inArray
(
this
.
value
,
values
)
>=
0
||
...
@@ -105,7 +115,7 @@ jQuery.fn.extend({
...
@@ -105,7 +115,7 @@ jQuery.fn.extend({
this
.
selectedIndex
=
-
1
;
this
.
selectedIndex
=
-
1
;
}
else
}
else
this
.
value
=
val
ue
;
this
.
value
=
val
;
});
});
}
}
});
});
...
...
src/manipulation.js
View file @
7d7a9600
...
@@ -138,6 +138,14 @@ jQuery.fn.extend({
...
@@ -138,6 +138,14 @@ jQuery.fn.extend({
domManip
:
function
(
args
,
table
,
callback
)
{
domManip
:
function
(
args
,
table
,
callback
)
{
var
fragment
,
scripts
,
cacheable
,
cached
,
cacheresults
,
first
;
var
fragment
,
scripts
,
cacheable
,
cached
,
cacheresults
,
first
;
var
value
=
args
[
0
];
if
(
jQuery
.
isFunction
(
value
)
)
{
return
this
.
each
(
function
()
{
args
[
0
]
=
value
.
call
(
this
);
return
jQuery
(
this
).
domManip
(
args
,
table
,
callback
);
});
};
if
(
this
[
0
]
)
{
if
(
this
[
0
]
)
{
if
(
args
.
length
===
1
&&
typeof
args
[
0
]
===
"string"
&&
args
[
0
].
length
<
512
&&
args
[
0
].
indexOf
(
"<option"
)
<
0
)
{
if
(
args
.
length
===
1
&&
typeof
args
[
0
]
===
"string"
&&
args
[
0
].
length
<
512
&&
args
[
0
].
indexOf
(
"<option"
)
<
0
)
{
...
...
test/unit/manipulation.js
View file @
7d7a9600
This diff is collapsed.
Click to expand it.
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