MCPcopy
hub / github.com/apache/caldera / fixCloneNodeIssues

Function fixCloneNodeIssues

static/jquery/jquery.js:5941–6007  ·  view source on GitHub ↗
( src, dest )

Source from the content-addressed store, hash-verified

5939}
5940
5941function fixCloneNodeIssues( src, dest ) {
5942 var nodeName, e, data;
5943
5944 // We do not need to do anything for non-Elements
5945 if ( dest.nodeType !== 1 ) {
5946 return;
5947 }
5948
5949 nodeName = dest.nodeName.toLowerCase();
5950
5951 // IE6-8 copies events bound via attachEvent when using cloneNode.
5952 if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
5953 data = jQuery._data( dest );
5954
5955 for ( e in data.events ) {
5956 jQuery.removeEvent( dest, e, data.handle );
5957 }
5958
5959 // Event data gets referenced instead of copied if the expando gets copied too
5960 dest.removeAttribute( jQuery.expando );
5961 }
5962
5963 // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
5964 if ( nodeName === "script" && dest.text !== src.text ) {
5965 disableScript( dest ).text = src.text;
5966 restoreScript( dest );
5967
5968 // IE6-10 improperly clones children of object elements using classid.
5969 // IE10 throws NoModificationAllowedError if parent is null, #12132.
5970 } else if ( nodeName === "object" ) {
5971 if ( dest.parentNode ) {
5972 dest.outerHTML = src.outerHTML;
5973 }
5974
5975 // This path appears unavoidable for IE9. When cloning an object
5976 // element in IE9, the outerHTML strategy above is not sufficient.
5977 // If the src has innerHTML and the destination does not,
5978 // copy the src.innerHTML into the dest.innerHTML. #10324
5979 if ( support.html5Clone && ( src.innerHTML && !jQuery.trim( dest.innerHTML ) ) ) {
5980 dest.innerHTML = src.innerHTML;
5981 }
5982
5983 } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
5984
5985 // IE6-8 fails to persist the checked state of a cloned checkbox
5986 // or radio button. Worse, IE6-7 fail to give the cloned element
5987 // a checked appearance if the defaultChecked value isn't also set
5988
5989 dest.defaultChecked = dest.checked = src.checked;
5990
5991 // IE6-7 get confused and end up setting the value of a cloned
5992 // checkbox/radio button to an empty string instead of "on"
5993 if ( dest.value !== src.value ) {
5994 dest.value = src.value;
5995 }
5996
5997 // IE6-8 fails to return the selected option to the default selected
5998 // state when cloning options

Callers 1

jquery.jsFile · 0.85

Calls 4

disableScriptFunction · 0.85
restoreScriptFunction · 0.85
trimMethod · 0.80
testMethod · 0.80

Tested by

no test coverage detected