Skip to content

Commit

Permalink
Fixed clone so that it now properly copies changes to the innerHTML i…
Browse files Browse the repository at this point in the history
…n IE. Unfortunately, IE stores some modifications to some attributes only as a property and they are still not copied properly. This is documented in ticket #1836.
  • Loading branch information
brandonaaron committed Dec 8, 2007
1 parent b3ec8ed commit ccf0550
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/core.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -292,9 +292,23 @@ jQuery.fn = jQuery.prototype = {
clone: function( events ) { clone: function( events ) {
// Do the clone // Do the clone
var ret = this.map(function(){ var ret = this.map(function(){
return this.outerHTML ? if ( jQuery.browser.msie ) {
jQuery( this.outerHTML )[0] : // IE copies events bound via attachEvent when
this.cloneNode( true ); // using cloneNode. Calling detachEvent on the
// clone will also remove the events from the orignal
// In order to get around this, we use innerHTML.
// Unfortunately, this means some modifications to
// attributes in IE that are actually only stored
// as properties will not be copied (such as the
// the name attribute on an input).
var clone = this.cloneNode(true),
container = document.createElement("div"),
container2 = document.createElement("div");
container.appendChild(clone);
container2.innerHTML = container.innerHTML;
return container2.firstChild;
} else
return this.cloneNode(true);
}); });


// Need to set the expando to null on the cloned set if it exists // Need to set the expando to null on the cloned set if it exists
Expand Down

0 comments on commit ccf0550

Please sign in to comment.