MCPcopy Create free account
hub / github.com/sql-js/sql.js / cloneFixAttributes

Function cloneFixAttributes

documentation/javascript/application.js:6814–6882  ·  view source on GitHub ↗
( src, dest )

Source from the content-addressed store, hash-verified

6812}
6813
6814function cloneFixAttributes( src, dest ) {
6815 var nodeName;
6816
6817 // We do not need to do anything for non-Elements
6818 if ( dest.nodeType !== 1 ) {
6819 return;
6820 }
6821
6822 // clearAttributes removes the attributes, which we don't want,
6823 // but also removes the attachEvent events, which we *do* want
6824 if ( dest.clearAttributes ) {
6825 dest.clearAttributes();
6826 }
6827
6828 // mergeAttributes, in contrast, only merges back on the
6829 // original attributes, not the events
6830 if ( dest.mergeAttributes ) {
6831 dest.mergeAttributes( src );
6832 }
6833
6834 nodeName = dest.nodeName.toLowerCase();
6835
6836 if ( nodeName === "object" ) {
6837 // IE6-10 improperly clones children of object elements using classid.
6838 // IE10 throws NoModificationAllowedError if parent is null, #12132.
6839 if ( dest.parentNode ) {
6840 dest.outerHTML = src.outerHTML;
6841 }
6842
6843 // This path appears unavoidable for IE9. When cloning an object
6844 // element in IE9, the outerHTML strategy above is not sufficient.
6845 // If the src has innerHTML and the destination does not,
6846 // copy the src.innerHTML into the dest.innerHTML. #10324
6847 if ( jQuery.support.html5Clone && (src.innerHTML && !jQuery.trim(dest.innerHTML)) ) {
6848 dest.innerHTML = src.innerHTML;
6849 }
6850
6851 } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
6852 // IE6-8 fails to persist the checked state of a cloned checkbox
6853 // or radio button. Worse, IE6-7 fail to give the cloned element
6854 // a checked appearance if the defaultChecked value isn't also set
6855
6856 dest.defaultChecked = dest.checked = src.checked;
6857
6858 // IE6-7 get confused and end up setting the value of a cloned
6859 // checkbox/radio button to an empty string instead of "on"
6860 if ( dest.value !== src.value ) {
6861 dest.value = src.value;
6862 }
6863
6864 // IE6-8 fails to return the selected option to the default selected
6865 // state when cloning options
6866 } else if ( nodeName === "option" ) {
6867 dest.selected = src.defaultSelected;
6868
6869 // IE6-8 fails to set the defaultValue to the correct value when
6870 // cloning other types of input fields
6871 } else if ( nodeName === "input" || nodeName === "textarea" ) {

Callers 1

application.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…