diff options
author | Brandon Aaron <brandon.aaron@gmail.com> | 2007-07-21 03:16:22 +0000 |
---|---|---|
committer | Brandon Aaron <brandon.aaron@gmail.com> | 2007-07-21 03:16:22 +0000 |
commit | 9b9a7932735d43a936c74084a613f21b250de6f9 (patch) | |
tree | 94044429f5f712ccbec08bf57638b9066e8d6ed4 | |
parent | 480aae72d3fe7c10eb51e310b88acc37c34f8bd8 (diff) | |
download | jquery-9b9a7932735d43a936c74084a613f21b250de6f9.tar.gz jquery-9b9a7932735d43a936c74084a613f21b250de6f9.zip |
selectedIndex is now cloned in IE (#1294)
-rw-r--r-- | src/jquery/jquery.js | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index d6d3d6a2d..b4202c853 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -852,27 +852,37 @@ jQuery.fn = jQuery.prototype = { * @cat DOM/Manipulation */ clone: function(deep) { - // Need to remove events on the element and its descendants - var $this = this.add(this.find("*")); - $this.each(function() { - this._$events = {}; - for (var type in this.$events) - this._$events[type] = jQuery.extend({},this.$events[type]); - }).unbind(); + if (jQuery.browser.msie) { + // Need to remove events on the element and its descendants + var $this = this.add(this.find("*")); + $this.each(function() { + this._$events = {}; + for (var type in this.$events) + this._$events[type] = jQuery.extend({},this.$events[type]); + }).unbind(); + } // Do the clone var r = this.pushStack( jQuery.map( this, function(a){ return a.cloneNode( deep != undefined ? deep : true ); }) ); - // Add the events back to the original and its descendants - $this.each(function() { - var events = this._$events; - for (var type in events) - for (var handler in events[type]) - jQuery.event.add(this, type, events[type][handler], events[type][handler].data); - this._$events = null; - }); + if (jQuery.browser.msie) { + // Add the events back to the original and its descendants + $this.each(function() { + var events = this._$events; + for (var type in events) + for (var handler in events[type]) + jQuery.event.add(this, type, events[type][handler], events[type][handler].data); + this._$events = null; + }); + + // set selected values of select elements + var selects = r.find('select'); + $this.filter('select').each(function(i) { + selects[i].selectedIndex = this.selectedIndex; + }); + } // Return the cloned set return r; |