Skip to content
Permalink
Browse files

Use a for loop rather than for/in loop when copying events, so that c…

…ode will work with an augmented Array.prototype. Fixes 7809.
  • Loading branch information...
dmethvin committed Dec 21, 2010
1 parent 291b1ed commit 4424bda377336342ce04ab5299bf1ce624cdb7b1
Showing with 8 additions and 5 deletions.
  1. +5 −5 src/manipulation.js
  2. +3 −0 test/unit/manipulation.js
@@ -370,14 +370,14 @@ function root( elem, cur ) {
}

function cloneCopyEvent(orig, ret) {
var i = 0;
var node = 0;

ret.each(function() {
if ( this.nodeType !== 1 || this.nodeName !== (orig[i] && orig[i].nodeName) ) {
if ( this.nodeType !== 1 || this.nodeName !== (orig[node] && orig[node].nodeName) ) {
return;
}

var oldData = jQuery.data( orig[i++] ),
var oldData = jQuery.data( orig[node++] ),
curData = jQuery.data( this, oldData ),
events = oldData && oldData.events;

@@ -386,8 +386,8 @@ function cloneCopyEvent(orig, ret) {
curData.events = {};

for ( var type in events ) {
for ( var handler in events[ type ] ) {
jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data );
for ( var i = 0, l = events[ type ].length; i < l; i++ ) {
jQuery.event.add( this, type, events[ type ][ i ], events[ type ][ i ].data );
}
}
}
@@ -1,5 +1,8 @@
module("manipulation");

// Ensure that an extended Array prototype doesn't break jQuery
Array.prototype.arrayProtoFn = function(arg) { throw("arrayProtoFn should not be called"); };

var bareObj = function(value) { return value; };
var functionReturningObj = function(value) { return (function() { return value; }); };

0 comments on commit 4424bda

Please sign in to comment.
You can’t perform that action at this time.