Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Don't use for-in loops on Arrays. Fixes #7817. Thanks to dmethvin.

Conflicts:
	src/manipulation.js
  • Loading branch information...
commit 82ac384b494258e17e2856ee2259475ecb0174ca 2 parents f28c774 + acab4ab
Colin Snover authored December 22, 2010
4  src/manipulation.js
@@ -390,8 +390,8 @@ function cloneCopyEvent(orig, ret) {
390 390
 			curData.events = {};
391 391
 
392 392
 			for ( var type in events ) {
393  
-				for ( var handler in events[ type ] ) {
394  
-					jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data );
  393
+				for ( var i = 0, l = events[ type ].length; i < l; i++ ) {
  394
+					jQuery.event.add( this, type, events[ type ][ i ], events[ type ][ i ].data );
395 395
 				}
396 396
 			}
397 397
 		}
2  src/xhr.js
@@ -87,7 +87,7 @@ jQuery.xhr = function( _native ) {
87 87
 		}
88 88
 		
89 89
 		// Apply option prefilters
90  
-		for (i in prefilters) {
  90
+		for ( i = 0; i < prefilters.length; i++ ) {
91 91
 			prefilters[i](s);
92 92
 		}
93 93
 		
3  test/unit/manipulation.js
... ...
@@ -1,5 +1,8 @@
1 1
 module("manipulation");
2 2
 
  3
+// Ensure that an extended Array prototype doesn't break jQuery
  4
+Array.prototype.arrayProtoFn = function(arg) { throw("arrayProtoFn should not be called"); };
  5
+
3 6
 var bareObj = function(value) { return value; };
4 7
 var functionReturningObj = function(value) { return (function() { return value; }); };
5 8
 

0 notes on commit 82ac384

Please sign in to comment.
Something went wrong with that request. Please try again.