Skip to content

Commit 252e834

Browse files
committed
fix(Angularjs) WIP - code cleanup
Prepares a single boolean return instead of several if return boolean statements. angular#4751
1 parent 9ba755e commit 252e834

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/Angular.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,15 @@ if (isNaN(msie)) {
167167
* String ...)
168168
*/
169169
function isArrayLike(obj) {
170-
var length
171-
if (obj == null || isWindow(obj)) {
172-
return false;
173-
}
174-
if(obj.nodeType === 1 && obj.hasChildNodes()) return true;
175-
if(obj.hasOwnProperty('length') && obj.hasOwnProperty('callee')) return true;
176-
length = obj.length;
177-
return isString(obj) || isArray(obj) || (
178-
!isObject(obj) && length === 0 || (
179-
typeof length === 'number' && length >= 0 && (length - 1) in obj));
170+
var length, objExists, isNodeList, isArguments, isSomeOtherObj;
171+
objExists = isDefined(obj) && obj !== null;
172+
length = objExists ? obj.length : undefined;
173+
isNodeList = objExists && obj.nodeType === 1 && obj.hasChildNodes();
174+
isArguments = objExists && obj.hasOwnProperty('length') && obj.hasOwnProperty('callee');
175+
isSomeOtherObj = objExists && !isArguments && !isNodeList && !isArray(obj) && !isString(obj) && (!isObject(obj) && length === 0 || (typeof length === 'number' && length >= 0 && (length - 1) in obj));
176+
177+
return objExists && !isWindow(obj) && (((obj.nodeType === 1 && obj.hasChildNodes()) || (obj.hasOwnProperty('length') && obj.hasOwnProperty('callee')) || isString(obj) || isArray(obj)) || (!isObject(obj) && length === 0 || (typeof length === 'number' && length >= 0 && (length - 1) in obj)) );
178+
180179
}
181180

182181
/**

0 commit comments

Comments
 (0)