mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-09 15:24:43 +00:00
parent
fc8034b352
commit
5b8c78843e
2 changed files with 12 additions and 6 deletions
|
|
@ -87,22 +87,21 @@ if (isNaN(msie)) {
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {*} obj
|
* @param {*} obj
|
||||||
* @return {boolean} Returns true if `obj` is an array or array-like object (NodeList, Arguments, ...)
|
* @return {boolean} Returns true if `obj` is an array or array-like object (NodeList, Arguments, String ...)
|
||||||
*/
|
*/
|
||||||
function isArrayLike(obj) {
|
function isArrayLike(obj) {
|
||||||
if (obj == null || isWindow(obj)) {
|
if (obj == null || isWindow(obj)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var length = obj.length;
|
var length = obj.length;
|
||||||
|
|
||||||
if (obj.nodeType === 1 && length) {
|
if (obj.nodeType === 1 && length) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isArray(obj) || !isFunction(obj) && (
|
return isString(obj) || isArray(obj) || length === 0 ||
|
||||||
length === 0 || typeof length === "number" && length > 0 && (length - 1) in obj
|
typeof length === 'number' && length > 0 && (length - 1) in obj;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -599,7 +598,7 @@ function isLeafNode (node) {
|
||||||
* * If a destination is provided, all of its elements (for array) or properties (for objects)
|
* * If a destination is provided, all of its elements (for array) or properties (for objects)
|
||||||
* are deleted and then all elements/properties from the source are copied to it.
|
* are deleted and then all elements/properties from the source are copied to it.
|
||||||
* * If `source` is not an object or array (inc. `null` and `undefined`), `source` is returned.
|
* * If `source` is not an object or array (inc. `null` and `undefined`), `source` is returned.
|
||||||
* * If `source` is identical to 'destination' an exception will be thrown.
|
* * If `source` is identical to 'destination' an exception will be thrown.
|
||||||
*
|
*
|
||||||
* Note: this function is used to augment the Object type in Angular expressions. See
|
* Note: this function is used to augment the Object type in Angular expressions. See
|
||||||
* {@link ng.$filter} for more information about Angular arrays.
|
* {@link ng.$filter} for more information about Angular arrays.
|
||||||
|
|
|
||||||
|
|
@ -461,6 +461,13 @@ describe('angular', function() {
|
||||||
expect(log).toEqual(['0:a', '1:b', '2:c']);
|
expect(log).toEqual(['0:a', '1:b', '2:c']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle string values like arrays', function() {
|
||||||
|
var log = [];
|
||||||
|
|
||||||
|
forEach('bar', function(value, key) { log.push(key + ':' + value)});
|
||||||
|
expect(log).toEqual(['0:b', '1:a', '2:r']);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should handle objects with length property as objects', function() {
|
it('should handle objects with length property as objects', function() {
|
||||||
var obj = {
|
var obj = {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue