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
7a5000a3
Commit
7a5000a3
authored
Dec 19, 2012
by
Oleg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify fixCloneNodeIssues helper
parent
329d5e1d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
42 deletions
+8
-42
manipulation.js
src/manipulation.js
+8
-42
No files found.
src/manipulation.js
View file @
7a5000a3
...
@@ -400,7 +400,7 @@ function cloneCopyEvent( src, dest ) {
...
@@ -400,7 +400,7 @@ function cloneCopyEvent( src, dest ) {
}
}
function
fixCloneNodeIssues
(
src
,
dest
)
{
function
fixCloneNodeIssues
(
src
,
dest
)
{
var
nodeName
,
data
,
e
;
var
nodeName
;
// We do not need to do anything for non-Elements
// We do not need to do anything for non-Elements
if
(
dest
.
nodeType
!==
1
)
{
if
(
dest
.
nodeType
!==
1
)
{
...
@@ -409,26 +409,7 @@ function fixCloneNodeIssues( src, dest ) {
...
@@ -409,26 +409,7 @@ function fixCloneNodeIssues( src, dest ) {
nodeName
=
dest
.
nodeName
.
toLowerCase
();
nodeName
=
dest
.
nodeName
.
toLowerCase
();
// IE6-8 copies events bound via attachEvent when using cloneNode.
if
(
nodeName
===
"object"
)
{
if
(
!
jQuery
.
support
.
noCloneEvent
&&
dest
[
jQuery
.
expando
]
)
{
data
=
jQuery
.
_data
(
dest
);
for
(
e
in
data
.
events
)
{
jQuery
.
removeEvent
(
dest
,
e
,
data
.
handle
);
}
// Event data gets referenced instead of copied if the expando gets copied too
dest
.
removeAttribute
(
jQuery
.
expando
);
}
// IE blanks contents when cloning scripts, and tries to evaluate newly-set text
if
(
nodeName
===
"script"
&&
dest
.
text
!==
src
.
text
)
{
disableScript
(
dest
).
text
=
src
.
text
;
restoreScript
(
dest
);
// IE6-10 improperly clones children of object elements using classid.
// IE10 throws NoModificationAllowedError if parent is null, #12132.
}
else
if
(
nodeName
===
"object"
)
{
if
(
dest
.
parentNode
)
{
if
(
dest
.
parentNode
)
{
dest
.
outerHTML
=
src
.
outerHTML
;
dest
.
outerHTML
=
src
.
outerHTML
;
}
}
...
@@ -437,30 +418,16 @@ function fixCloneNodeIssues( src, dest ) {
...
@@ -437,30 +418,16 @@ function fixCloneNodeIssues( src, dest ) {
// element in IE9, the outerHTML strategy above is not sufficient.
// element in IE9, the outerHTML strategy above is not sufficient.
// If the src has innerHTML and the destination does not,
// If the src has innerHTML and the destination does not,
// copy the src.innerHTML into the dest.innerHTML. #10324
// copy the src.innerHTML into the dest.innerHTML. #10324
if
(
jQuery
.
support
.
html5Clone
&&
(
src
.
innerHTML
&&
!
jQuery
.
trim
(
dest
.
innerHTML
)
)
)
{
if
(
src
.
innerHTML
&&
!
jQuery
.
trim
(
dest
.
innerHTML
)
)
{
dest
.
innerHTML
=
src
.
innerHTML
;
dest
.
innerHTML
=
src
.
innerHTML
;
}
}
// IE9-10 fails to persist the checked state of a cloned checkbox or radio button.
}
else
if
(
nodeName
===
"input"
&&
manipulation_rcheckableType
.
test
(
src
.
type
)
)
{
}
else
if
(
nodeName
===
"input"
&&
manipulation_rcheckableType
.
test
(
src
.
type
)
)
{
// IE6-8 fails to persist the checked state of a cloned checkbox
dest
.
checked
=
src
.
checked
;
// or radio button. Worse, IE6-7 fail to give the cloned element
// a checked appearance if the defaultChecked value isn't also set
dest
.
defaultChecked
=
dest
.
checked
=
src
.
checked
;
// IE6-7 get confused and end up setting the value of a cloned
// IE9-10 fails to return the selected option to the default selected
// checkbox/radio button to an empty string instead of "on"
if
(
dest
.
value
!==
src
.
value
)
{
dest
.
value
=
src
.
value
;
}
// IE6-8 fails to return the selected option to the default selected
// state when cloning options
// state when cloning options
}
else
if
(
nodeName
===
"option"
)
{
dest
.
defaultSelected
=
dest
.
selected
=
src
.
defaultSelected
;
// IE6-8 fails to set the defaultValue to the correct value when
// 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
;
}
}
...
@@ -528,14 +495,13 @@ jQuery.extend({
...
@@ -528,14 +495,13 @@ jQuery.extend({
clone
=
elem
.
cloneNode
(
true
);
clone
=
elem
.
cloneNode
(
true
);
// IE<=8 does not properly clone detached, unknown element nodes
// IE<=8 does not properly clone detached, unknown element nodes
if
(
(
!
jQuery
.
support
.
noCloneEvent
||
!
jQuery
.
support
.
noCloneChecked
)
&&
if
(
!
jQuery
.
support
.
noCloneChecked
&&
(
elem
.
nodeType
===
1
||
elem
.
nodeType
===
11
)
&&
!
jQuery
.
isXMLDoc
(
elem
)
)
{
(
elem
.
nodeType
===
1
||
elem
.
nodeType
===
11
)
&&
!
jQuery
.
isXMLDoc
(
elem
)
)
{
// We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
// We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
destElements
=
getAll
(
clone
);
destElements
=
getAll
(
clone
);
srcElements
=
getAll
(
elem
);
srcElements
=
getAll
(
elem
);
// Fix
all
IE cloning issues
// Fix IE cloning issues
for
(
i
=
0
;
(
node
=
srcElements
[
i
])
!=
null
;
++
i
)
{
for
(
i
=
0
;
(
node
=
srcElements
[
i
])
!=
null
;
++
i
)
{
// Ensure that the destination node is not null; Fixes #9587
// Ensure that the destination node is not null; Fixes #9587
if
(
destElements
[
i
]
)
{
if
(
destElements
[
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