]> source.dussan.org Git - jquery.git/commitdiff
Use a for loop rather than for/in loop when copying events, so that code will work... 140/head
authorDave Methvin <dave.methvin@gmail.com>
Tue, 21 Dec 2010 03:23:59 +0000 (22:23 -0500)
committerDave Methvin <dave.methvin@gmail.com>
Tue, 21 Dec 2010 03:23:59 +0000 (22:23 -0500)
src/manipulation.js
test/unit/manipulation.js

index 7dea3493c2947f305963c9b79fe3ccd2b34f40c8..9d70a7b03f5ec2ecf87ba54c6d453105be097ec0 100644 (file)
@@ -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 );
                                }
                        }
                }
index d49029eb8dfb374cb4e4461ca4bf283076225f06..cbc0b7715f843aa69b4a0ac743fcaf2436265d97 100644 (file)
@@ -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; }); };