aboutsummaryrefslogtreecommitdiffstats
path: root/src/core.js
diff options
context:
space:
mode:
authorBrandon Aaron <brandon.aaron@gmail.com>2007-12-08 23:03:10 +0000
committerBrandon Aaron <brandon.aaron@gmail.com>2007-12-08 23:03:10 +0000
commitccf055033ab165c677590b42fa0ca7e0a29e9fb7 (patch)
treeb2e6ceffafd73e82241b53d9c162bc60195f0d1c /src/core.js
parentb3ec8edddd9261eef490f8317144e9c68c888819 (diff)
downloadjquery-ccf055033ab165c677590b42fa0ca7e0a29e9fb7.tar.gz
jquery-ccf055033ab165c677590b42fa0ca7e0a29e9fb7.zip
Fixed clone so that it now properly copies changes to the innerHTML in 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.
Diffstat (limited to 'src/core.js')
-rw-r--r--src/core.js20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/core.js b/src/core.js
index 313cdfa75..27a57283e 100644
--- a/src/core.js
+++ b/src/core.js
@@ -292,9 +292,23 @@ jQuery.fn = jQuery.prototype = {
clone: function( events ) {
// Do the clone
var ret = this.map(function(){
- return this.outerHTML ?
- jQuery( this.outerHTML )[0] :
- this.cloneNode( true );
+ if ( jQuery.browser.msie ) {
+ // IE copies events bound via attachEvent when
+ // 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