191191msie = document . documentMode ;
192192
193193
194- function isNodeList ( obj ) {
195- return typeof obj . length == 'number' &&
196- typeof obj . item == 'function' ;
197- }
198-
199194/**
200195 * @private
201196 * @param {* } obj
@@ -207,15 +202,20 @@ function isArrayLike(obj) {
207202 // `null`, `undefined` and `window` are not array-like
208203 if ( obj == null || isWindow ( obj ) ) return false ;
209204
210- // arrays and strings are array like
211- if ( isArray ( obj ) || isString ( obj ) ) return true ;
205+ // arrays, strings and jQuery/jqLite objects are array like
206+ // * jqLite is either the jQuery or jqLite constructor function
207+ // * we have to check the existance of jqLite first as this method is called
208+ // via the forEach method when constructing the jqLite object in the first place
209+ if ( isArray ( obj ) || isString ( obj ) || ( jqLite && obj instanceof jqLite ) ) return true ;
212210
213211 // Support: iOS 8.2 (not reproducible in simulator)
214212 // "length" in obj used to prevent JIT error (gh-11508)
215213 var length = "length" in Object ( obj ) && obj . length ;
216214
217- // node lists and objects with suitable length characteristics are array-like
218- return ( isNumber ( length ) && length >= 0 && ( length - 1 ) in obj ) || isNodeList ( obj ) ;
215+ // NodeList objects (with `item` method) and
216+ // other objects with suitable length characteristics are array-like
217+ return isNumber ( length ) &&
218+ ( length >= 0 && ( length - 1 ) in obj || typeof obj . item == 'function' ) ;
219219}
220220
221221/**
0 commit comments