Skip to content

Commit

Permalink
Fix #10878. Clear oldIE special change/submit flags on a clone.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmethvin committed Jan 28, 2012
1 parent 633ca9c commit c746f79
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/manipulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,11 @@ function cloneFixAttributes( src, dest ) {
// Event data gets referenced instead of copied if the expando
// gets copied too
dest.removeAttribute( jQuery.expando );

// Clear flags for bubbling special change/submit events, they must
// be reattached when the newly cloned events are first activated
dest.removeAttribute( "_submit_attached" );
dest.removeAttribute( "_change_attached" );
}

jQuery.buildFragment = function( args, nodes, scripts ) {
Expand Down
14 changes: 12 additions & 2 deletions test/delegatetest.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ <h2>Submit Tests</h2>
});

// Events we want to track in row-order
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(" "),
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(" "),
counter = 0;
blinker = function(event){
if ( !counter ) {
Expand Down Expand Up @@ -172,7 +172,7 @@ <h2>Submit Tests</h2>
$("#changes thead td").each(function(){
var id = "#"+this.id,
$cell = $('<td></td>');
if ( api == "on" ) {
if ( api == "onX" ) {
$(this).find("input, button, select, textarea").each(function(){
this["on"+type] = function(e){ e = $.event.fix(e||event); e.data = $cell; blinker.call(this, e); };
});
Expand All @@ -186,6 +186,16 @@ <h2>Submit Tests</h2>
$("#changes tbody").append($row);
}

// Ensure that cloned elements get the delegated event magic; this is
// implementation-specific knowledge but otherwise impossible to test.
// The beforeactivate event attaches a direct-bound change event.
// (Only care about the live change for this third select element.)
var sel1 = $("#select-one select:first-child");
if ( typeof(sel1[0].fireEvent) !== "undefined" ) {
sel1.trigger( "beforeactivate" ).clone().appendTo("#select-one");
//alert($("#select-one select").map(function(){ return this._change_attached || "undef"; }).get().join("|"));
}

jQuery.fn.blink = function(){
return this
.css("backgroundColor","green")
Expand Down

0 comments on commit c746f79

Please sign in to comment.