+ expect(log).toEqual(['name: misko', 'gender: male']);
+ ```
*
* @param {Object|Array} obj Object to iterate over.
* @param {Function} iterator Iterator function.
@@ -292,7 +313,9 @@ function forEach(obj, iterator, context) {
if (obj) {
if (isFunction(obj)){
for (key in obj) {
- if (key != 'prototype' && key != 'length' && key != 'name' && obj.hasOwnProperty(key)) {
+ // Need to check if hasOwnProperty exists,
+ // as on IE8 the result of querySelectorAll is an object without a hasOwnProperty function
+ if (key != 'prototype' && key != 'length' && key != 'name' && (!obj.hasOwnProperty || obj.hasOwnProperty(key))) {
iterator.call(context, obj[key], key);
}
}
@@ -346,7 +369,7 @@ function reverseParams(iteratorFn) {
* the number string gets longer over time, and it can also overflow, where as the nextId
* will grow much slower, it is a string, and it will never overflow.
*
- * @returns an unique alpha-numeric string
+ * @returns {string} an unique alpha-numeric string
*/
function nextUid() {
var index = uid.length;
@@ -388,6 +411,7 @@ function setHashKey(obj, h) {
/**
* @ngdoc function
* @name angular.extend
+ * @module ng
* @function
*
* @description
@@ -424,17 +448,18 @@ function inherit(parent, extra) {
/**
* @ngdoc function
* @name angular.noop
+ * @module ng
* @function
*
* @description
* A function that performs no operations. This function can be useful when writing code in the
* functional style.
-
+ ```js
function foo(callback) {
var result = calculateResult();
(callback || angular.noop)(result);
}
-
+ ```
*/
function noop() {}
noop.$inject = [];
@@ -443,17 +468,18 @@ noop.$inject = [];
/**
* @ngdoc function
* @name angular.identity
+ * @module ng
* @function
*
* @description
* A function that returns its first argument. This function is useful when writing code in the
* functional style.
*
-
+ ```
*/
function identity($) {return $;}
identity.$inject = [];
@@ -464,6 +490,7 @@ function valueFn(value) {return function() {return value;};}
/**
* @ngdoc function
* @name angular.isUndefined
+ * @module ng
* @function
*
* @description
@@ -472,12 +499,13 @@ function valueFn(value) {return function() {return value;};}
* @param {*} value Reference to check.
* @returns {boolean} True if `value` is undefined.
*/
-function isUndefined(value){return typeof value == 'undefined';}
+function isUndefined(value){return typeof value === 'undefined';}
/**
* @ngdoc function
* @name angular.isDefined
+ * @module ng
* @function
*
* @description
@@ -486,27 +514,29 @@ function isUndefined(value){return typeof value == 'undefined';}
* @param {*} value Reference to check.
* @returns {boolean} True if `value` is defined.
*/
-function isDefined(value){return typeof value != 'undefined';}
+function isDefined(value){return typeof value !== 'undefined';}
/**
* @ngdoc function
* @name angular.isObject
+ * @module ng
* @function
*
* @description
* Determines if a reference is an `Object`. Unlike `typeof` in JavaScript, `null`s are not
- * considered to be objects.
+ * considered to be objects. Note that JavaScript arrays are objects.
*
* @param {*} value Reference to check.
* @returns {boolean} True if `value` is an `Object` but not `null`.
*/
-function isObject(value){return value != null && typeof value == 'object';}
+function isObject(value){return value != null && typeof value === 'object';}
/**
* @ngdoc function
* @name angular.isString
+ * @module ng
* @function
*
* @description
@@ -515,12 +545,13 @@ function isObject(value){return value != null && typeof value == 'object';}
* @param {*} value Reference to check.
* @returns {boolean} True if `value` is a `String`.
*/
-function isString(value){return typeof value == 'string';}
+function isString(value){return typeof value === 'string';}
/**
* @ngdoc function
* @name angular.isNumber
+ * @module ng
* @function
*
* @description
@@ -529,12 +560,13 @@ function isString(value){return typeof value == 'string';}
* @param {*} value Reference to check.
* @returns {boolean} True if `value` is a `Number`.
*/
-function isNumber(value){return typeof value == 'number';}
+function isNumber(value){return typeof value === 'number';}
/**
* @ngdoc function
* @name angular.isDate
+ * @module ng
* @function
*
* @description
@@ -544,13 +576,14 @@ function isNumber(value){return typeof value == 'number';}
* @returns {boolean} True if `value` is a `Date`.
*/
function isDate(value){
- return toString.apply(value) == '[object Date]';
+ return toString.call(value) === '[object Date]';
}
/**
* @ngdoc function
* @name angular.isArray
+ * @module ng
* @function
*
* @description
@@ -560,13 +593,14 @@ function isDate(value){
* @returns {boolean} True if `value` is an `Array`.
*/
function isArray(value) {
- return toString.apply(value) == '[object Array]';
+ return toString.call(value) === '[object Array]';
}
/**
* @ngdoc function
* @name angular.isFunction
+ * @module ng
* @function
*
* @description
@@ -575,7 +609,7 @@ function isArray(value) {
* @param {*} value Reference to check.
* @returns {boolean} True if `value` is a `Function`.
*/
-function isFunction(value){return typeof value == 'function';}
+function isFunction(value){return typeof value === 'function';}
/**
@@ -586,7 +620,7 @@ function isFunction(value){return typeof value == 'function';}
* @returns {boolean} True if `value` is a `RegExp`.
*/
function isRegExp(value) {
- return toString.apply(value) == '[object RegExp]';
+ return toString.call(value) === '[object RegExp]';
}
@@ -608,12 +642,17 @@ function isScope(obj) {
function isFile(obj) {
- return toString.apply(obj) === '[object File]';
+ return toString.call(obj) === '[object File]';
+}
+
+
+function isBlob(obj) {
+ return toString.call(obj) === '[object Blob]';
}
function isBoolean(value) {
- return typeof value == 'boolean';
+ return typeof value === 'boolean';
}
@@ -635,6 +674,7 @@ var trim = (function() {
/**
* @ngdoc function
* @name angular.isElement
+ * @module ng
* @function
*
* @description
@@ -644,9 +684,9 @@ var trim = (function() {
* @returns {boolean} True if `value` is a DOM element (or wrapped jQuery element).
*/
function isElement(node) {
- return node &&
+ return !!(node &&
(node.nodeName // we are a direct element
- || (node.on && node.find)); // we have an on and find method part of jQuery API
+ || (node.prop && node.attr && node.find))); // we have an on and find method part of jQuery API
}
/**
@@ -717,7 +757,7 @@ function includes(array, obj) {
function indexOf(array, obj) {
if (array.indexOf) return array.indexOf(obj);
- for ( var i = 0; i < array.length; i++) {
+ for (var i = 0; i < array.length; i++) {
if (obj === array[i]) return i;
}
return -1;
@@ -745,6 +785,7 @@ function isLeafNode (node) {
/**
* @ngdoc function
* @name angular.copy
+ * @module ng
* @function
*
* @description
@@ -763,8 +804,8 @@ function isLeafNode (node) {
* @returns {*} The copy or updated `destination`, if `destination` was specified.
*
* @example
-
-
+
+