Skip to content

Commit c746f79

Browse files
committed
Fix #10878. Clear oldIE special change/submit flags on a clone.
1 parent 633ca9c commit c746f79

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/manipulation.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,11 @@ function cloneFixAttributes( src, dest ) {
461461
// Event data gets referenced instead of copied if the expando
462462
// gets copied too
463463
dest.removeAttribute( jQuery.expando );
464+
465+
// Clear flags for bubbling special change/submit events, they must
466+
// be reattached when the newly cloned events are first activated
467+
dest.removeAttribute( "_submit_attached" );
468+
dest.removeAttribute( "_change_attached" );
464469
}
465470

466471
jQuery.buildFragment = function( args, nodes, scripts ) {

test/delegatetest.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ <h2>Submit Tests</h2>
143143
});
144144

145145
// Events we want to track in row-order
146-
var events = "bind-change live-change on-change bind-propertychange live-beforeactivate live-focusin bind-focus live-beforedeactivate live-focusout bind-blur live-click live-keydown".split(" "),
146+
var events = "bind-change live-change onX-change bind-propertychange live-beforeactivate live-focusin bind-focus live-beforedeactivate live-focusout bind-blur live-click live-keydown".split(" "),
147147
counter = 0;
148148
blinker = function(event){
149149
if ( !counter ) {
@@ -172,7 +172,7 @@ <h2>Submit Tests</h2>
172172
$("#changes thead td").each(function(){
173173
var id = "#"+this.id,
174174
$cell = $('<td></td>');
175-
if ( api == "on" ) {
175+
if ( api == "onX" ) {
176176
$(this).find("input, button, select, textarea").each(function(){
177177
this["on"+type] = function(e){ e = $.event.fix(e||event); e.data = $cell; blinker.call(this, e); };
178178
});
@@ -186,6 +186,16 @@ <h2>Submit Tests</h2>
186186
$("#changes tbody").append($row);
187187
}
188188

189+
// Ensure that cloned elements get the delegated event magic; this is
190+
// implementation-specific knowledge but otherwise impossible to test.
191+
// The beforeactivate event attaches a direct-bound change event.
192+
// (Only care about the live change for this third select element.)
193+
var sel1 = $("#select-one select:first-child");
194+
if ( typeof(sel1[0].fireEvent) !== "undefined" ) {
195+
sel1.trigger( "beforeactivate" ).clone().appendTo("#select-one");
196+
//alert($("#select-one select").map(function(){ return this._change_attached || "undef"; }).get().join("|"));
197+
}
198+
189199
jQuery.fn.blink = function(){
190200
return this
191201
.css("backgroundColor","green")

0 commit comments

Comments
 (0)