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
4b70f006
Commit
4b70f006
authored
Dec 09, 2009
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made .clone(true) also copy over element data. Fixes #4191.
parent
f6a0bf68
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
8 deletions
+7
-8
manipulation.js
src/manipulation.js
+1
-7
manipulation.js
test/unit/manipulation.js
+6
-1
No files found.
src/manipulation.js
View file @
4b70f006
...
@@ -277,13 +277,7 @@ function cloneCopyEvent(orig, ret) {
...
@@ -277,13 +277,7 @@ function cloneCopyEvent(orig, ret) {
return
;
return
;
}
}
var
events
=
jQuery
.
data
(
orig
[
i
],
"events"
);
jQuery
.
data
(
this
,
jQuery
.
data
(
orig
[
i
++
]
)
);
for
(
var
type
in
events
)
{
for
(
var
handler
in
events
[
type
]
)
{
jQuery
.
event
.
add
(
this
,
type
,
events
[
type
][
handler
],
events
[
type
][
handler
].
data
);
}
}
});
});
}
}
...
...
test/unit/manipulation.js
View file @
4b70f006
...
@@ -549,7 +549,7 @@ test("replaceAll(String|Element|Array<Element>|jQuery)", function() {
...
@@ -549,7 +549,7 @@ test("replaceAll(String|Element|Array<Element>|jQuery)", function() {
});
});
test
(
"clone()"
,
function
()
{
test
(
"clone()"
,
function
()
{
expect
(
28
);
expect
(
30
);
equals
(
'This is a normal link: Yahoo'
,
jQuery
(
'#en'
).
text
(),
'Assert text for #en'
);
equals
(
'This is a normal link: Yahoo'
,
jQuery
(
'#en'
).
text
(),
'Assert text for #en'
);
var
clone
=
jQuery
(
'#yahoo'
).
clone
();
var
clone
=
jQuery
(
'#yahoo'
).
clone
();
equals
(
'Try them out:Yahoo'
,
jQuery
(
'#first'
).
append
(
clone
).
text
(),
'Check for clone'
);
equals
(
'Try them out:Yahoo'
,
jQuery
(
'#first'
).
append
(
clone
).
text
(),
'Check for clone'
);
...
@@ -594,6 +594,11 @@ test("clone()", function() {
...
@@ -594,6 +594,11 @@ test("clone()", function() {
div
=
div
.
clone
(
true
);
div
=
div
.
clone
(
true
);
equals
(
div
.
length
,
1
,
"One element cloned"
);
equals
(
div
.
length
,
1
,
"One element cloned"
);
equals
(
div
[
0
].
nodeName
.
toUpperCase
(),
"DIV"
,
"DIV element cloned"
);
equals
(
div
[
0
].
nodeName
.
toUpperCase
(),
"DIV"
,
"DIV element cloned"
);
div
=
jQuery
(
"<div/>"
).
data
({
a
:
true
,
b
:
true
});
div
=
div
.
clone
(
true
);
equals
(
div
.
data
(
"a"
),
true
,
"Data cloned."
);
equals
(
div
.
data
(
"b"
),
true
,
"Data cloned."
);
});
});
if
(
!
isLocal
)
{
if
(
!
isLocal
)
{
...
...
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