This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +12
-6
lines changed
2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -87,22 +87,21 @@ if (isNaN(msie)) {
87
87
/**
88
88
* @private
89
89
* @param {* } obj
90
- * @return {boolean } Returns true if `obj` is an array or array-like object (NodeList, Arguments, ...)
90
+ * @return {boolean } Returns true if `obj` is an array or array-like object (NodeList, Arguments, String ...)
91
91
*/
92
92
function isArrayLike ( obj ) {
93
93
if ( obj == null || isWindow ( obj ) ) {
94
94
return false ;
95
95
}
96
-
96
+
97
97
var length = obj . length ;
98
98
99
99
if ( obj . nodeType === 1 && length ) {
100
100
return true ;
101
101
}
102
102
103
- return isArray ( obj ) || ! isFunction ( obj ) && (
104
- length === 0 || typeof length === "number" && length > 0 && ( length - 1 ) in obj
105
- ) ;
103
+ return isString ( obj ) || isArray ( obj ) || length === 0 ||
104
+ typeof length === 'number' && length > 0 && ( length - 1 ) in obj ;
106
105
}
107
106
108
107
/**
@@ -599,7 +598,7 @@ function isLeafNode (node) {
599
598
* * If a destination is provided, all of its elements (for array) or properties (for objects)
600
599
* are deleted and then all elements/properties from the source are copied to it.
601
600
* * If `source` is not an object or array (inc. `null` and `undefined`), `source` is returned.
602
- * * If `source` is identical to 'destination' an exception will be thrown.
601
+ * * If `source` is identical to 'destination' an exception will be thrown.
603
602
*
604
603
* Note: this function is used to augment the Object type in Angular expressions. See
605
604
* {@link ng.$filter} for more information about Angular arrays.
Original file line number Diff line number Diff line change @@ -461,6 +461,13 @@ describe('angular', function() {
461
461
expect ( log ) . toEqual ( [ '0:a' , '1:b' , '2:c' ] ) ;
462
462
} ) ;
463
463
464
+ it ( 'should handle string values like arrays' , function ( ) {
465
+ var log = [ ] ;
466
+
467
+ forEach ( 'bar' , function ( value , key ) { log . push ( key + ':' + value ) } ) ;
468
+ expect ( log ) . toEqual ( [ '0:b' , '1:a' , '2:r' ] ) ;
469
+ } ) ;
470
+
464
471
465
472
it ( 'should handle objects with length property as objects' , function ( ) {
466
473
var obj = {
You can’t perform that action at this time.
0 commit comments