| 5832 | } |
| 5833 | |
| 5834 | function cloneFixAttributes( src, dest ) { |
| 5835 | var nodeName; |
| 5836 | |
| 5837 | // We do not need to do anything for non-Elements |
| 5838 | if ( dest.nodeType !== 1 ) { |
| 5839 | return; |
| 5840 | } |
| 5841 | |
| 5842 | // clearAttributes removes the attributes, which we don't want, |
| 5843 | // but also removes the attachEvent events, which we *do* want |
| 5844 | if ( dest.clearAttributes ) { |
| 5845 | dest.clearAttributes(); |
| 5846 | } |
| 5847 | |
| 5848 | // mergeAttributes, in contrast, only merges back on the |
| 5849 | // original attributes, not the events |
| 5850 | if ( dest.mergeAttributes ) { |
| 5851 | dest.mergeAttributes( src ); |
| 5852 | } |
| 5853 | |
| 5854 | nodeName = dest.nodeName.toLowerCase(); |
| 5855 | |
| 5856 | // IE6-8 fail to clone children inside object elements that use |
| 5857 | // the proprietary classid attribute value (rather than the type |
| 5858 | // attribute) to identify the type of content to display |
| 5859 | if ( nodeName === "object" ) { |
| 5860 | dest.outerHTML = src.outerHTML; |
| 5861 | |
| 5862 | } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) { |
| 5863 | // IE6-8 fails to persist the checked state of a cloned checkbox |
| 5864 | // or radio button. Worse, IE6-7 fail to give the cloned element |
| 5865 | // a checked appearance if the defaultChecked value isn't also set |
| 5866 | if ( src.checked ) { |
| 5867 | dest.defaultChecked = dest.checked = src.checked; |
| 5868 | } |
| 5869 | |
| 5870 | // IE6-7 get confused and end up setting the value of a cloned |
| 5871 | // checkbox/radio button to an empty string instead of "on" |
| 5872 | if ( dest.value !== src.value ) { |
| 5873 | dest.value = src.value; |
| 5874 | } |
| 5875 | |
| 5876 | // IE6-8 fails to return the selected option to the default selected |
| 5877 | // state when cloning options |
| 5878 | } else if ( nodeName === "option" ) { |
| 5879 | dest.selected = src.defaultSelected; |
| 5880 | |
| 5881 | // IE6-8 fails to set the defaultValue to the correct value when |
| 5882 | // cloning other types of input fields |
| 5883 | } else if ( nodeName === "input" || nodeName === "textarea" ) { |
| 5884 | dest.defaultValue = src.defaultValue; |
| 5885 | } |
| 5886 | |
| 5887 | // Event data gets referenced instead of copied if the expando |
| 5888 | // gets copied too |
| 5889 | dest.removeAttribute( jQuery.expando ); |
| 5890 | } |
| 5891 | |