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
dec2804c
Commit
dec2804c
authored
Feb 17, 2012
by
Richard Gibson
Committed by
Dave Methvin
Feb 24, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #11359: preserve contents for cloned scripts
parent
f3656832
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
manipulation.js
src/manipulation.js
+4
-0
manipulation.js
test/unit/manipulation.js
+9
-0
No files found.
src/manipulation.js
View file @
dec2804c
...
@@ -456,6 +456,10 @@ function cloneFixAttributes( src, dest ) {
...
@@ -456,6 +456,10 @@ function cloneFixAttributes( src, dest ) {
// cloning other types of input fields
// cloning other types of input fields
}
else
if
(
nodeName
===
"input"
||
nodeName
===
"textarea"
)
{
}
else
if
(
nodeName
===
"input"
||
nodeName
===
"textarea"
)
{
dest
.
defaultValue
=
src
.
defaultValue
;
dest
.
defaultValue
=
src
.
defaultValue
;
// IE blanks contents when cloning scripts
}
else
if
(
nodeName
===
"script"
&&
dest
.
text
!==
src
.
text
)
{
dest
.
text
=
src
.
text
;
}
}
// Event data gets referenced instead of copied if the expando
// Event data gets referenced instead of copied if the expando
...
...
test/unit/manipulation.js
View file @
dec2804c
...
@@ -1169,6 +1169,15 @@ test("clone()", function() {
...
@@ -1169,6 +1169,15 @@ test("clone()", function() {
equal
(
jQuery
(
"body"
).
clone
().
children
()[
0
].
id
,
"qunit-header"
,
"Make sure cloning body works"
);
equal
(
jQuery
(
"body"
).
clone
().
children
()[
0
].
id
,
"qunit-header"
,
"Make sure cloning body works"
);
});
});
test
(
"clone(script type=non-javascript) (#11359)"
,
function
()
{
expect
(
3
);
var
src
=
jQuery
(
"<script type='text/filler'>Lorem ipsum dolor sit amet</script><q><script type='text/filler'>consectetur adipiscing elit</script></q>"
);
var
dest
=
src
.
clone
();
equal
(
dest
[
0
].
text
,
"Lorem ipsum dolor sit amet"
,
"Cloning preserves script text"
);
equal
(
dest
.
last
().
html
(),
src
.
last
().
html
(),
"Cloning preserves nested script text"
);
ok
(
/^
\s
*<scr.pt
\s
+type=
[
'"
]?
text
\/
filler
[
'"
]?\s
*>consectetur adipiscing elit<
\/
scr.pt>
\s
*$/i
.
test
(
dest
.
last
().
html
()
),
"Cloning preserves nested script text"
);
});
test
(
"clone(form element) (Bug #3879, #6655)"
,
function
()
{
test
(
"clone(form element) (Bug #3879, #6655)"
,
function
()
{
expect
(
5
);
expect
(
5
);
var
element
=
jQuery
(
"<select><option>Foo</option><option selected>Bar</option></select>"
);
var
element
=
jQuery
(
"<select><option>Foo</option><option selected>Bar</option></select>"
);
...
...
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