diff --git a/config/karma.conf.angular.1.2.js b/config/karma.conf.angular.1.2.js
index 68cf43c..7bd782f 100644
--- a/config/karma.conf.angular.1.2.js
+++ b/config/karma.conf.angular.1.2.js
@@ -7,8 +7,8 @@ module.exports = function(config) {
// list of files / patterns to load in the browser
files: [
- 'test/lib/angular.1.2.16.js',
- 'test/lib/angular-mocks.1.2.16.js',
+ 'test/lib/angular.1.2.22.js',
+ 'test/lib/angular-mocks.1.2.22.js',
'dist/angular-validation.js',
'dist/angular-validation-rule.js',
'test/unit/*.js'
diff --git a/index.html b/index.html
index dff9458..9cea810 100644
--- a/index.html
+++ b/index.html
@@ -205,7 +205,7 @@
Angular Validation.
-
+
diff --git a/test/lib/angular-mocks.1.2.16.js b/test/lib/angular-mocks.1.2.22.js
similarity index 98%
rename from test/lib/angular-mocks.1.2.16.js
rename to test/lib/angular-mocks.1.2.22.js
index 384f504..15f1880 100644
--- a/test/lib/angular-mocks.1.2.16.js
+++ b/test/lib/angular-mocks.1.2.22.js
@@ -1,5 +1,5 @@
/**
- * @license AngularJS v1.2.16
+ * @license AngularJS v1.2.22
* (c) 2010-2014 Google, Inc. http://angularjs.org
* License: MIT
*/
@@ -462,8 +462,8 @@
iteration = 0,
skipApply = (angular.isDefined(invokeApply) && !invokeApply);
- count = (angular.isDefined(count)) ? count : 0,
- promise.then(null, null, fn);
+ count = (angular.isDefined(count)) ? count : 0;
+ promise.then(null, null, fn);
promise.$$intervalId = nextRepeatId;
@@ -888,7 +888,7 @@
* development please see {@link ngMockE2E.$httpBackend e2e $httpBackend mock}.
*
* During unit testing, we want our unit tests to run quickly and have no external dependencies so
- * we don’t want to send [XHR](https://developer.mozilla.org/en/xmlhttprequest) or
+ * we don’t want to send [XHR](https://developer.mozilla.org/en/xmlhttprequest) or
* [JSONP](http://en.wikipedia.org/wiki/JSONP) requests to a real server. All we really need is
* to verify whether a certain request has been sent or not, or alternatively just let the
* application make requests, respond with pre-trained responses and assert that the end result is
@@ -900,7 +900,7 @@
* When an Angular application needs some data from a server, it calls the $http service, which
* sends the request to a real server using $httpBackend service. With dependency injection, it is
* easy to inject $httpBackend mock (which has the same API as $httpBackend) and use it to verify
- * the requests and respond with some testing data without sending a request to real server.
+ * the requests and respond with some testing data without sending a request to a real server.
*
* There are two ways to specify what test data should be returned as http responses by the mock
* backend when the code under test makes http requests:
@@ -1043,7 +1043,7 @@
var controller = createController();
$httpBackend.flush();
- // now you don’t care about the authentication, but
+ // now you don’t care about the authentication, but
// the controller will still send the request and
// $httpBackend will respond without you having to
// specify the expectation and response for this request
@@ -1194,10 +1194,10 @@
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled.
*
- * - respond –
+ * - respond –
* `{function([status,] data[, headers, statusText])
* | function(function(method, url, data, headers)}`
- * – The respond method takes a set of static data to be returned or a function that can
+ * – The respond method takes a set of static data to be returned or a function that can
* return an array containing response status (number), response data (string), response
* headers (Object), and the text for the status (string).
*/
@@ -1312,10 +1312,10 @@
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
* request is handled.
*
- * - respond –
+ * - respond –
* `{function([status,] data[, headers, statusText])
* | function(function(method, url, data, headers)}`
- * – The respond method takes a set of static data to be returned or a function that can
+ * – The respond method takes a set of static data to be returned or a function that can
* return an array containing response status (number), response data (string), response
* headers (Object), and the text for the status (string).
*/
@@ -1722,11 +1722,12 @@
/**
* @ngdoc module
* @name ngMock
+ * @packageName angular-mocks
* @description
*
* # ngMock
*
- * The `ngMock` module providers support to inject and mock Angular services into unit tests.
+ * The `ngMock` module provides support to inject and mock Angular services into unit tests.
* In addition, ngMock also extends various core ng services such that they can be
* inspected and controlled in a synchronous manner within test code.
*
@@ -1751,6 +1752,7 @@
* @ngdoc module
* @name ngMockE2E
* @module ngMockE2E
+ * @packageName angular-mocks
* @description
*
* The `ngMockE2E` is an angular module which contains mocks suitable for end-to-end testing.
@@ -1784,7 +1786,7 @@
* use the `passThrough` request handler of `when` instead of `respond`.
*
* Additionally, we don't want to manually have to flush mocked out requests like we do during unit
- * testing. For this reason the e2e $httpBackend automatically flushes mocked out requests
+ * testing. For this reason the e2e $httpBackend flushes mocked out requests
* automatically, closely simulating the behavior of the XMLHttpRequest object.
*
* To setup the application to run with this http backend, you have to create a module that depends
@@ -1800,7 +1802,9 @@
*
* // adds a new phone to the phones array
* $httpBackend.whenPOST('/phones').respond(function(method, url, data) {
- * phones.push(angular.fromJson(data));
+ * var phone = angular.fromJson(data);
+ * phones.push(phone);
+ * return [200, phone, {}];
* });
* $httpBackend.whenGET(/^\/templates\//).passThrough();
* //...
@@ -1825,13 +1829,13 @@
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
* control how a matched request is handled.
*
- * - respond –
+ * - respond –
* `{function([status,] data[, headers, statusText])
* | function(function(method, url, data, headers)}`
- * – The respond method takes a set of static data to be returned or a function that can return
+ * – The respond method takes a set of static data to be returned or a function that can return
* an array containing response status (number), response data (string), response headers
* (Object), and the text for the status (string).
- * - passThrough – `{function()}` – Any request matching a backend definition with
+ * - passThrough – `{function()}` – Any request matching a backend definition with
* `passThrough` handler will be passed through to the real backend (an XHR request will be made
* to the server.)
*/
@@ -1956,13 +1960,19 @@
};
- beforeEach(function() {
+ (window.beforeEach || window.setup)(function() {
currentSpec = this;
});
- afterEach(function() {
+ (window.afterEach || window.teardown)(function() {
var injector = currentSpec.$injector;
+ angular.forEach(currentSpec.$modules, function(module) {
+ if (module && module.$$hashKey) {
+ module.$$hashKey = undefined;
+ }
+ });
+
currentSpec.$injector = null;
currentSpec.$modules = null;
currentSpec = null;
@@ -2002,7 +2012,7 @@
* @param {...(string|Function|Object)} fns any number of modules which are represented as string
* aliases or as anonymous module initialization functions. The modules are used to
* configure the injector. The 'ng' and 'ngMock' modules are automatically loaded. If an
- * object literal is passed they will be register as values in the module, the key being
+ * object literal is passed they will be registered as values in the module, the key being
* the module name and the value being what is returned.
*/
window.module = angular.mock.module = function() {
diff --git a/test/lib/angular.1.2.16.js b/test/lib/angular.1.2.22.js
similarity index 90%
rename from test/lib/angular.1.2.16.js
rename to test/lib/angular.1.2.22.js
index 93e7e25..191e933 100644
--- a/test/lib/angular.1.2.16.js
+++ b/test/lib/angular.1.2.22.js
@@ -1,5 +1,5 @@
/**
- * @license AngularJS v1.2.16
+ * @license AngularJS v1.2.22
* (c) 2010-2014 Google, Inc. http://angularjs.org
* License: MIT
*/
@@ -68,7 +68,7 @@
return match;
});
- message = message + '\nhttp://errors.angularjs.org/1.2.16/' +
+ message = message + '\nhttp://errors.angularjs.org/1.2.22/' +
(module ? module + '/' : '') + code;
for (i = 2; i < arguments.length; i++) {
message = message + (i == 2 ? '?' : '&') + 'p' + (i-2) + '=' +
@@ -80,89 +80,88 @@
}
/* We need to tell jshint what variables are being exported */
- /* global
- -angular,
- -msie,
- -jqLite,
- -jQuery,
- -slice,
- -push,
- -toString,
- -ngMinErr,
- -_angular,
- -angularModule,
- -nodeName_,
- -uid,
-
- -lowercase,
- -uppercase,
- -manualLowercase,
- -manualUppercase,
- -nodeName_,
- -isArrayLike,
- -forEach,
- -sortedKeys,
- -forEachSorted,
- -reverseParams,
- -nextUid,
- -setHashKey,
- -extend,
- -int,
- -inherit,
- -noop,
- -identity,
- -valueFn,
- -isUndefined,
- -isDefined,
- -isObject,
- -isString,
- -isNumber,
- -isDate,
- -isArray,
- -isFunction,
- -isRegExp,
- -isWindow,
- -isScope,
- -isFile,
- -isBlob,
- -isBoolean,
- -trim,
- -isElement,
- -makeMap,
- -map,
- -size,
- -includes,
- -indexOf,
- -arrayRemove,
- -isLeafNode,
- -copy,
- -shallowCopy,
- -equals,
- -csp,
- -concat,
- -sliceArgs,
- -bind,
- -toJsonReplacer,
- -toJson,
- -fromJson,
- -toBoolean,
- -startingTag,
- -tryDecodeURIComponent,
- -parseKeyValue,
- -toKeyValue,
- -encodeUriSegment,
- -encodeUriQuery,
- -angularInit,
- -bootstrap,
- -snake_case,
- -bindJQuery,
- -assertArg,
- -assertArgFn,
- -assertNotHasOwnProperty,
- -getter,
- -getBlockElements,
- -hasOwnProperty,
-
+ /* global angular: true,
+ msie: true,
+ jqLite: true,
+ jQuery: true,
+ slice: true,
+ push: true,
+ toString: true,
+ ngMinErr: true,
+ angularModule: true,
+ nodeName_: true,
+ uid: true,
+ VALIDITY_STATE_PROPERTY: true,
+
+ lowercase: true,
+ uppercase: true,
+ manualLowercase: true,
+ manualUppercase: true,
+ nodeName_: true,
+ isArrayLike: true,
+ forEach: true,
+ sortedKeys: true,
+ forEachSorted: true,
+ reverseParams: true,
+ nextUid: true,
+ setHashKey: true,
+ extend: true,
+ int: true,
+ inherit: true,
+ noop: true,
+ identity: true,
+ valueFn: true,
+ isUndefined: true,
+ isDefined: true,
+ isObject: true,
+ isString: true,
+ isNumber: true,
+ isDate: true,
+ isArray: true,
+ isFunction: true,
+ isRegExp: true,
+ isWindow: true,
+ isScope: true,
+ isFile: true,
+ isBlob: true,
+ isBoolean: true,
+ isPromiseLike: true,
+ trim: true,
+ isElement: true,
+ makeMap: true,
+ map: true,
+ size: true,
+ includes: true,
+ indexOf: true,
+ arrayRemove: true,
+ isLeafNode: true,
+ copy: true,
+ shallowCopy: true,
+ equals: true,
+ csp: true,
+ concat: true,
+ sliceArgs: true,
+ bind: true,
+ toJsonReplacer: true,
+ toJson: true,
+ fromJson: true,
+ toBoolean: true,
+ startingTag: true,
+ tryDecodeURIComponent: true,
+ parseKeyValue: true,
+ toKeyValue: true,
+ encodeUriSegment: true,
+ encodeUriQuery: true,
+ angularInit: true,
+ bootstrap: true,
+ snake_case: true,
+ bindJQuery: true,
+ assertArg: true,
+ assertArgFn: true,
+ assertNotHasOwnProperty: true,
+ getter: true,
+ getBlockElements: true,
+ hasOwnProperty: true,
*/
////////////////////////////////////
@@ -182,11 +181,15 @@
*
*/
+// The name of a form control's ValidityState property.
+// This is used so that it's possible for internal tests to create mock ValidityStates.
+ var VALIDITY_STATE_PROPERTY = 'validity';
+
/**
* @ngdoc function
* @name angular.lowercase
* @module ng
- * @function
+ * @kind function
*
* @description Converts the specified string to lowercase.
* @param {string} string String to be converted to lowercase.
@@ -199,7 +202,7 @@
* @ngdoc function
* @name angular.uppercase
* @module ng
- * @function
+ * @kind function
*
* @description Converts the specified string to uppercase.
* @param {string} string String to be converted to uppercase.
@@ -240,8 +243,6 @@
toString = Object.prototype.toString,
ngMinErr = minErr('ng'),
-
- _angular = window.angular,
/** @name angular */
angular = window.angular || (window.angular = {}),
angularModule,
@@ -283,7 +284,7 @@
* @ngdoc function
* @name angular.forEach
* @module ng
- * @function
+ * @kind function
*
* @description
* Invokes the `iterator` function once for each item in `obj` collection, which can be either an
@@ -297,7 +298,7 @@
```js
var values = {name: 'misko', gender: 'male'};
var log = [];
- angular.forEach(values, function(value, key){
+ angular.forEach(values, function(value, key) {
this.push(key + ': ' + value);
}, log);
expect(log).toEqual(['name: misko', 'gender: male']);
@@ -311,7 +312,7 @@
function forEach(obj, iterator, context) {
var key;
if (obj) {
- if (isFunction(obj)){
+ if (isFunction(obj)) {
for (key in obj) {
// Need to check if hasOwnProperty exists,
// as on IE8 the result of querySelectorAll is an object without a hasOwnProperty function
@@ -319,11 +320,12 @@
iterator.call(context, obj[key], key);
}
}
+ } else if (isArray(obj) || isArrayLike(obj)) {
+ for (key = 0; key < obj.length; key++) {
+ iterator.call(context, obj[key], key);
+ }
} else if (obj.forEach && obj.forEach !== forEach) {
obj.forEach(iterator, context);
- } else if (isArrayLike(obj)) {
- for (key = 0; key < obj.length; key++)
- iterator.call(context, obj[key], key);
} else {
for (key in obj) {
if (obj.hasOwnProperty(key)) {
@@ -412,7 +414,7 @@
* @ngdoc function
* @name angular.extend
* @module ng
- * @function
+ * @kind function
*
* @description
* Extends the destination object `dst` by copying all of the properties from the `src` object(s)
@@ -424,9 +426,9 @@
*/
function extend(dst) {
var h = dst.$$hashKey;
- forEach(arguments, function(obj){
+ forEach(arguments, function(obj) {
if (obj !== dst) {
- forEach(obj, function(value, key){
+ forEach(obj, function(value, key) {
dst[key] = value;
});
}
@@ -449,7 +451,7 @@
* @ngdoc function
* @name angular.noop
* @module ng
- * @function
+ * @kind function
*
* @description
* A function that performs no operations. This function can be useful when writing code in the
@@ -469,7 +471,7 @@
* @ngdoc function
* @name angular.identity
* @module ng
- * @function
+ * @kind function
*
* @description
* A function that returns its first argument. This function is useful when writing code in the
@@ -491,7 +493,7 @@
* @ngdoc function
* @name angular.isUndefined
* @module ng
- * @function
+ * @kind function
*
* @description
* Determines if a reference is undefined.
@@ -506,7 +508,7 @@
* @ngdoc function
* @name angular.isDefined
* @module ng
- * @function
+ * @kind function
*
* @description
* Determines if a reference is defined.
@@ -521,7 +523,7 @@
* @ngdoc function
* @name angular.isObject
* @module ng
- * @function
+ * @kind function
*
* @description
* Determines if a reference is an `Object`. Unlike `typeof` in JavaScript, `null`s are not
@@ -537,7 +539,7 @@
* @ngdoc function
* @name angular.isString
* @module ng
- * @function
+ * @kind function
*
* @description
* Determines if a reference is a `String`.
@@ -552,7 +554,7 @@
* @ngdoc function
* @name angular.isNumber
* @module ng
- * @function
+ * @kind function
*
* @description
* Determines if a reference is a `Number`.
@@ -567,7 +569,7 @@
* @ngdoc function
* @name angular.isDate
* @module ng
- * @function
+ * @kind function
*
* @description
* Determines if a value is a date.
@@ -575,7 +577,7 @@
* @param {*} value Reference to check.
* @returns {boolean} True if `value` is a `Date`.
*/
- function isDate(value){
+ function isDate(value) {
return toString.call(value) === '[object Date]';
}
@@ -584,7 +586,7 @@
* @ngdoc function
* @name angular.isArray
* @module ng
- * @function
+ * @kind function
*
* @description
* Determines if a reference is an `Array`.
@@ -592,16 +594,20 @@
* @param {*} value Reference to check.
* @returns {boolean} True if `value` is an `Array`.
*/
- function isArray(value) {
- return toString.call(value) === '[object Array]';
- }
-
+ var isArray = (function() {
+ if (!isFunction(Array.isArray)) {
+ return function(value) {
+ return toString.call(value) === '[object Array]';
+ };
+ }
+ return Array.isArray;
+ })();
/**
* @ngdoc function
* @name angular.isFunction
* @module ng
- * @function
+ * @kind function
*
* @description
* Determines if a reference is a `Function`.
@@ -656,6 +662,11 @@
}
+ function isPromiseLike(obj) {
+ return obj && isFunction(obj.then);
+ }
+
+
var trim = (function() {
// native trim is way faster: http://jsperf.com/angular-trim-test
// but IE doesn't have it... :-(
@@ -675,7 +686,7 @@
* @ngdoc function
* @name angular.isElement
* @module ng
- * @function
+ * @kind function
*
* @description
* Determines if a reference is a DOM element (or wrapped jQuery element).
@@ -693,7 +704,7 @@
* @param str 'key1,key2,...'
* @returns {object} in the form of {key1:true, key2:true, ...}
*/
- function makeMap(str){
+ function makeMap(str) {
var obj = {}, items = str.split(","), i;
for ( i = 0; i < items.length; i++ )
obj[ items[i] ] = true;
@@ -740,7 +751,7 @@
if (isArray(obj) || isString(obj)) {
return obj.length;
- } else if (isObject(obj)){
+ } else if (isObject(obj)) {
for (key in obj)
if (!ownPropsOnly || obj.hasOwnProperty(key))
count++;
@@ -786,7 +797,7 @@
* @ngdoc function
* @name angular.copy
* @module ng
- * @function
+ * @kind function
*
* @description
* Creates a deep copy of `source`, which should be an object or an array.
@@ -804,9 +815,9 @@
* @returns {*} The copy or updated `destination`, if `destination` was specified.
*
* @example
-
+
-
+
*/
- function copy(source, destination){
+ function copy(source, destination, stackSource, stackDest) {
if (isWindow(source) || isScope(source)) {
throw ngMinErr('cpws',
"Can't copy! Making copies of Window or Scope instances is not supported.");
@@ -849,52 +861,83 @@
destination = source;
if (source) {
if (isArray(source)) {
- destination = copy(source, []);
+ destination = copy(source, [], stackSource, stackDest);
} else if (isDate(source)) {
destination = new Date(source.getTime());
} else if (isRegExp(source)) {
- destination = new RegExp(source.source);
+ destination = new RegExp(source.source, source.toString().match(/[^\/]*$/)[0]);
+ destination.lastIndex = source.lastIndex;
} else if (isObject(source)) {
- destination = copy(source, {});
+ destination = copy(source, {}, stackSource, stackDest);
}
}
} else {
if (source === destination) throw ngMinErr('cpi',
"Can't copy! Source and destination are identical.");
+
+ stackSource = stackSource || [];
+ stackDest = stackDest || [];
+
+ if (isObject(source)) {
+ var index = indexOf(stackSource, source);
+ if (index !== -1) return stackDest[index];
+
+ stackSource.push(source);
+ stackDest.push(destination);
+ }
+
+ var result;
if (isArray(source)) {
destination.length = 0;
for ( var i = 0; i < source.length; i++) {
- destination.push(copy(source[i]));
+ result = copy(source[i], null, stackSource, stackDest);
+ if (isObject(source[i])) {
+ stackSource.push(source[i]);
+ stackDest.push(result);
+ }
+ destination.push(result);
}
} else {
var h = destination.$$hashKey;
- forEach(destination, function(value, key){
+ forEach(destination, function(value, key) {
delete destination[key];
});
for ( var key in source) {
- destination[key] = copy(source[key]);
+ result = copy(source[key], null, stackSource, stackDest);
+ if (isObject(source[key])) {
+ stackSource.push(source[key]);
+ stackDest.push(result);
+ }
+ destination[key] = result;
}
setHashKey(destination,h);
}
+
}
return destination;
}
/**
- * Create a shallow copy of an object
+ * Creates a shallow copy of an object, an array or a primitive
*/
function shallowCopy(src, dst) {
- dst = dst || {};
+ if (isArray(src)) {
+ dst = dst || [];
+
+ for ( var i = 0; i < src.length; i++) {
+ dst[i] = src[i];
+ }
+ } else if (isObject(src)) {
+ dst = dst || {};
- for(var key in src) {
- // shallowCopy is only ever called by $compile nodeLinkFn, which has control over src
- // so we don't need to worry about using our custom hasOwnProperty here
- if (src.hasOwnProperty(key) && !(key.charAt(0) === '$' && key.charAt(1) === '$')) {
- dst[key] = src[key];
+ for (var key in src) {
+ if (hasOwnProperty.call(src, key) && !(key.charAt(0) === '$' && key.charAt(1) === '$')) {
+ dst[key] = src[key];
+ }
}
}
- return dst;
+ return dst || src;
}
@@ -902,7 +945,7 @@
* @ngdoc function
* @name angular.equals
* @module ng
- * @function
+ * @kind function
*
* @description
* Determines if two objects or two values are equivalent. Supports value types, regular
@@ -914,7 +957,7 @@
* * Both objects or values are of the same type and all of their properties are equal by
* comparing them with `angular.equals`.
* * Both values are NaN. (In JavaScript, NaN == NaN => false. But we consider two NaN as equal)
- * * Both values represent the same regular expression (In JavasScript,
+ * * Both values represent the same regular expression (In JavaScript,
* /abc/ == /abc/ => false. But we consider two regular expressions as equal when their textual
* representation matches).
*
@@ -967,12 +1010,25 @@
return false;
}
+ var csp = function() {
+ if (isDefined(csp.isActive_)) return csp.isActive_;
+
+ var active = !!(document.querySelector('[ng-csp]') ||
+ document.querySelector('[data-ng-csp]'));
+
+ if (!active) {
+ try {
+ /* jshint -W031, -W054 */
+ new Function('');
+ /* jshint +W031, +W054 */
+ } catch (e) {
+ active = true;
+ }
+ }
+
+ return (csp.isActive_ = active);
+ };
- function csp() {
- return (document.securityPolicy && document.securityPolicy.isActive) ||
- (document.querySelector &&
- !!(document.querySelector('[ng-csp]') || document.querySelector('[data-ng-csp]')));
- }
function concat(array1, array2, index) {
@@ -989,7 +1045,7 @@
* @ngdoc function
* @name angular.bind
* @module ng
- * @function
+ * @kind function
*
* @description
* Returns a function which calls function `fn` bound to `self` (`self` becomes the `this` for
@@ -1045,7 +1101,7 @@
* @ngdoc function
* @name angular.toJson
* @module ng
- * @function
+ * @kind function
*
* @description
* Serializes input into a JSON-formatted string. Properties with leading $ characters will be
@@ -1065,7 +1121,7 @@
* @ngdoc function
* @name angular.fromJson
* @module ng
- * @function
+ * @kind function
*
* @description
* Deserializes a JSON string.
@@ -1142,13 +1198,13 @@
*/
function parseKeyValue(/**string*/keyValue) {
var obj = {}, key_value, key;
- forEach((keyValue || "").split('&'), function(keyValue){
+ forEach((keyValue || "").split('&'), function(keyValue) {
if ( keyValue ) {
- key_value = keyValue.split('=');
+ key_value = keyValue.replace(/\+/g,'%20').split('=');
key = tryDecodeURIComponent(key_value[0]);
if ( isDefined(key) ) {
var val = isDefined(key_value[1]) ? tryDecodeURIComponent(key_value[1]) : true;
- if (!obj[key]) {
+ if (!hasOwnProperty.call(obj, key)) {
obj[key] = val;
} else if(isArray(obj[key])) {
obj[key].push(val);
@@ -1322,7 +1378,7 @@
*
* Angular will detect if it has been loaded into the browser more than once and only allow the
* first loaded script to be bootstrapped and will report a warning to the browser console for
- * each of the subsequent scripts. This prevents strange results in applications, where otherwise
+ * each of the subsequent scripts. This prevents strange results in applications, where otherwise
* multiple instances of Angular try to work on the DOM.
*
*
@@ -1404,7 +1460,7 @@
}
var SNAKE_CASE_REGEXP = /[A-Z]/g;
- function snake_case(name, separator){
+ function snake_case(name, separator) {
separator = separator || '_';
return name.replace(SNAKE_CASE_REGEXP, function(letter, pos) {
return (pos ? separator : '') + letter.toLowerCase();
@@ -1414,8 +1470,9 @@
function bindJQuery() {
// bind to jQuery if present;
jQuery = window.jQuery;
- // reset to jQuery or default to us.
- if (jQuery) {
+ // Use jQuery if it exists with proper functionality, otherwise default to us.
+ // Angular 1.2+ requires jQuery 1.7.1+ for on()/off() support.
+ if (jQuery && jQuery.fn.on) {
jqLite = jQuery;
extend(jQuery.fn, {
scope: JQLitePrototype.scope,
@@ -1451,7 +1508,7 @@
}
assertArg(isFunction(arg), name, 'not a function, got ' +
- (arg && typeof arg == 'object' ? arg.constructor.name || 'Object' : typeof arg));
+ (arg && typeof arg === 'object' ? arg.constructor.name || 'Object' : typeof arg));
return arg;
}
@@ -1561,7 +1618,7 @@
*
* # Module
*
- * A module is a collection of services, directives, filters, and configuration information.
+ * A module is a collection of services, directives, controllers, filters, and configuration information.
* `angular.module` is used to configure the {@link auto.$injector $injector}.
*
* ```js
@@ -1589,9 +1646,9 @@
* {@link angular.bootstrap} to simplify this process for you.
*
* @param {!string} name The name of the module to create or retrieve.
- <<<<<* @param {!Array.=} requires If specified then new module is being created. If
- >>>>>* unspecified then the module is being retrieved for further configuration.
- * @param {Function} configFn Optional configuration function for the module. Same as
+ * @param {!Array.=} requires If specified then new module is being created. If
+ * unspecified then the module is being retrieved for further configuration.
+ * @param {Function=} configFn Optional configuration function for the module. Same as
* {@link angular.Module#config Module#config()}.
* @returns {module} new module with the {@link angular.Module} api.
*/
@@ -1783,6 +1840,8 @@
* configuration.
* @description
* Use this method to register work which needs to be performed on module loading.
+ * For more about how to configure services, see
+ * {@link providers#providers_provider-recipe Provider Recipe}.
*/
config: config,
@@ -1826,8 +1885,7 @@
}
- /* global
- angularModule: true,
+ /* global angularModule: true,
version: true,
$LocaleProvider,
@@ -1912,18 +1970,18 @@
* An object that contains information about the current AngularJS version. This object has the
* following properties:
*
- * - `full` – `{string}` – Full version string, such as "0.9.18".
- * - `major` – `{number}` – Major version number, such as "0".
- * - `minor` – `{number}` – Minor version number, such as "9".
- * - `dot` – `{number}` – Dot version number, such as "18".
- * - `codeName` – `{string}` – Code name of the release, such as "jiggling-armfat".
+ * - `full` – `{string}` – Full version string, such as "0.9.18".
+ * - `major` – `{number}` – Major version number, such as "0".
+ * - `minor` – `{number}` – Minor version number, such as "9".
+ * - `dot` – `{number}` – Dot version number, such as "18".
+ * - `codeName` – `{string}` – Code name of the release, such as "jiggling-armfat".
*/
var version = {
- full: '1.2.16', // all of these placeholder strings will be replaced by grunt's
+ full: '1.2.22', // all of these placeholder strings will be replaced by grunt's
major: 1, // package task
minor: 2,
- dot: 16,
- codeName: 'badger-enumeration'
+ dot: 22,
+ codeName: 'finicky-pleasure'
};
@@ -1936,11 +1994,11 @@
'element': jqLite,
'forEach': forEach,
'injector': createInjector,
- 'noop':noop,
- 'bind':bind,
+ 'noop': noop,
+ 'bind': bind,
'toJson': toJson,
'fromJson': fromJson,
- 'identity':identity,
+ 'identity': identity,
'isUndefined': isUndefined,
'isDefined': isDefined,
'isString': isString,
@@ -2047,12 +2105,10 @@
]);
}
- /* global
-
- -JQLitePrototype,
- -addEventListenerFn,
- -removeEventListenerFn,
- -BOOLEAN_ATTR
+ /* global JQLitePrototype: true,
+ addEventListenerFn: true,
+ removeEventListenerFn: true,
+ BOOLEAN_ATTR: true
*/
//////////////////////////////////
@@ -2063,7 +2119,7 @@
* @ngdoc function
* @name angular.element
* @module ng
- * @function
+ * @kind function
*
* @description
* Wraps a raw DOM element or HTML string as a [jQuery](http://jquery.com) element.
@@ -2145,8 +2201,9 @@
* @returns {Object} jQuery object.
*/
+ JQLite.expando = 'ng339';
+
var jqCache = JQLite.cache = {},
- jqName = JQLite.expando = 'ng-' + new Date().getTime(),
jqId = 1,
addEventListenerFn = (window.document.addEventListener
? function(element, type, fn) {element.addEventListener(type, fn, false);}
@@ -2356,7 +2413,7 @@
}
function jqLiteRemoveData(element, name) {
- var expandoId = element[jqName],
+ var expandoId = element.ng339,
expandoStore = jqCache[expandoId];
if (expandoStore) {
@@ -2370,17 +2427,17 @@
jqLiteOff(element);
}
delete jqCache[expandoId];
- element[jqName] = undefined; // ie does not allow deletion of attributes on elements.
+ element.ng339 = undefined; // don't delete DOM expandos. IE and Chrome don't like it
}
}
function jqLiteExpandoStore(element, key, value) {
- var expandoId = element[jqName],
+ var expandoId = element.ng339,
expandoStore = jqCache[expandoId || -1];
if (isDefined(value)) {
if (!expandoStore) {
- element[jqName] = expandoId = jqNextId();
+ element.ng339 = expandoId = jqNextId();
expandoStore = jqCache[expandoId] = {};
}
expandoStore[key] = value;
@@ -2465,25 +2522,22 @@
}
function jqLiteInheritedData(element, name, value) {
- element = jqLite(element);
-
// if element is the document object work with the html element instead
// this makes $(document).scope() possible
- if(element[0].nodeType == 9) {
- element = element.find('html');
+ if(element.nodeType == 9) {
+ element = element.documentElement;
}
var names = isArray(name) ? name : [name];
- while (element.length) {
- var node = element[0];
+ while (element) {
for (var i = 0, ii = names.length; i < ii; i++) {
- if ((value = element.data(names[i])) !== undefined) return value;
+ if ((value = jqLite.data(element, names[i])) !== undefined) return value;
}
// If dealing with a document fragment node with a host element, and no parent, use the host
// element as the parent. This enables directives within a Shadow DOM or polyfilled Shadow DOM
// to lookup parent controllers.
- element = jqLite(node.parentNode || (node.nodeType === 11 && node.host));
+ element = element.parentNode || (element.nodeType === 11 && element.host);
}
}
@@ -2558,18 +2612,25 @@
return booleanAttr && BOOLEAN_ELEMENTS[element.nodeName] && booleanAttr;
}
+ forEach({
+ data: jqLiteData,
+ removeData: jqLiteRemoveData
+ }, function(fn, name) {
+ JQLite[name] = fn;
+ });
+
forEach({
data: jqLiteData,
inheritedData: jqLiteInheritedData,
scope: function(element) {
// Can't use jqLiteData here directly so we stay compatible with jQuery!
- return jqLite(element).data('$scope') || jqLiteInheritedData(element.parentNode || element, ['$isolateScope', '$scope']);
+ return jqLite.data(element, '$scope') || jqLiteInheritedData(element.parentNode || element, ['$isolateScope', '$scope']);
},
isolateScope: function(element) {
// Can't use jqLiteData here directly so we stay compatible with jQuery!
- return jqLite(element).data('$isolateScope') || jqLite(element).data('$isolateScopeNoTemplate');
+ return jqLite.data(element, '$isolateScope') || jqLite.data(element, '$isolateScopeNoTemplate');
},
controller: jqLiteController,
@@ -2699,6 +2760,7 @@
*/
JQLite.prototype[name] = function(arg1, arg2) {
var i, key;
+ var nodeCount = this.length;
// jqLiteHasClass has only two arguments, but is a getter-only fn, so we need to special-case it
// in a way that survives minification.
@@ -2708,7 +2770,7 @@
if (isObject(arg1)) {
// we are a write, but the object properties are the key/values
- for (i = 0; i < this.length; i++) {
+ for (i = 0; i < nodeCount; i++) {
if (fn === jqLiteData) {
// data() takes the whole object in jQuery
fn(this[i], arg1);
@@ -2722,9 +2784,10 @@
return this;
} else {
// we are a read, so read the first child.
+ // TODO: do we still need this?
var value = fn.$dv;
// Only if we have $dv do we iterate over all, otherwise it is just the first element.
- var jj = (value === undefined) ? Math.min(this.length, 1) : this.length;
+ var jj = (value === undefined) ? Math.min(nodeCount, 1) : nodeCount;
for (var j = 0; j < jj; j++) {
var nodeValue = fn(this[j], arg1, arg2);
value = value ? value + nodeValue : nodeValue;
@@ -2733,7 +2796,7 @@
}
} else {
// we are a write, so apply to all children
- for (i = 0; i < this.length; i++) {
+ for (i = 0; i < nodeCount; i++) {
fn(this[i], arg1, arg2);
}
// return self for chaining
@@ -2994,19 +3057,37 @@
clone: jqLiteClone,
- triggerHandler: function(element, eventName, eventData) {
+ triggerHandler: function(element, event, extraParameters) {
+
+ var dummyEvent, eventFnsCopy, handlerArgs;
+ var eventName = event.type || event;
var eventFns = (jqLiteExpandoStore(element, 'events') || {})[eventName];
- eventData = eventData || [];
+ if (eventFns) {
- var event = [{
- preventDefault: noop,
- stopPropagation: noop
- }];
+ // Create a dummy event to pass to the handlers
+ dummyEvent = {
+ preventDefault: function() { this.defaultPrevented = true; },
+ isDefaultPrevented: function() { return this.defaultPrevented === true; },
+ stopPropagation: noop,
+ type: eventName,
+ target: element
+ };
- forEach(eventFns, function(fn) {
- fn.apply(element, event.concat(eventData));
- });
+ // If a custom event was provided then extend our dummy event with it
+ if (event.type) {
+ dummyEvent = extend(dummyEvent, event);
+ }
+
+ // Copy event handlers in case event handlers array is modified during execution.
+ eventFnsCopy = shallowCopy(eventFns);
+ handlerArgs = extraParameters ? [dummyEvent].concat(extraParameters) : [dummyEvent];
+
+ forEach(eventFnsCopy, function(fn) {
+ fn.apply(element, handlerArgs);
+ });
+
+ }
}
}, function(fn, name){
/**
@@ -3045,16 +3126,16 @@
* @returns {string} hash string such that the same input will have the same hash string.
* The resulting string key is in 'type:hashKey' format.
*/
- function hashKey(obj) {
+ function hashKey(obj, nextUidFn) {
var objType = typeof obj,
key;
- if (objType == 'object' && obj !== null) {
+ if (objType == 'function' || (objType == 'object' && obj !== null)) {
if (typeof (key = obj.$$hashKey) == 'function') {
// must invoke on object to keep the right this
key = obj.$$hashKey();
} else if (key === undefined) {
- key = obj.$$hashKey = nextUid();
+ key = obj.$$hashKey = (nextUidFn || nextUid)();
}
} else {
key = obj;
@@ -3066,7 +3147,13 @@
/**
* HashMap which can use objects as keys
*/
- function HashMap(array){
+ function HashMap(array, isolatedUid) {
+ if (isolatedUid) {
+ var uid = 0;
+ this.nextUid = function() {
+ return ++uid;
+ };
+ }
forEach(array, this.put, this);
}
HashMap.prototype = {
@@ -3076,7 +3163,7 @@
* @param value value to store can be any type
*/
put: function(key, value) {
- this[hashKey(key)] = value;
+ this[hashKey(key, this.nextUid)] = value;
},
/**
@@ -3084,7 +3171,7 @@
* @returns {Object} the value for the key
*/
get: function(key) {
- return this[hashKey(key)];
+ return this[hashKey(key, this.nextUid)];
},
/**
@@ -3092,7 +3179,7 @@
* @param key
*/
remove: function(key) {
- var value = this[key = hashKey(key)];
+ var value = this[key = hashKey(key, this.nextUid)];
delete this[key];
return value;
}
@@ -3102,7 +3189,7 @@
* @ngdoc function
* @module ng
* @name angular.injector
- * @function
+ * @kind function
*
* @description
* Creates an injector function that can be used for retrieving services as well as for
@@ -3129,7 +3216,7 @@
*
* Sometimes you want to get access to the injector of a currently running Angular app
* from outside Angular. Perhaps, you want to inject and compile some markup after the
- * application has been bootstrapped. You can do this using extra `injector()` added
+ * application has been bootstrapped. You can do this using the extra `injector()` added
* to JQuery/jqLite elements. See {@link angular.element}.
*
* *This is fairly rare but could be the case if a third party library is injecting the
@@ -3170,7 +3257,7 @@
argDecl,
last;
- if (typeof fn == 'function') {
+ if (typeof fn === 'function') {
if (!($inject = fn.$inject)) {
$inject = [];
if (fn.length) {
@@ -3199,7 +3286,7 @@
/**
* @ngdoc service
* @name $injector
- * @function
+ * @kind function
*
* @description
*
@@ -3242,7 +3329,7 @@
* minification, and obfuscation tools since these tools change the argument names.
*
* ## `$inject` Annotation
- * By adding a `$inject` property onto a function the injection parameters can be specified.
+ * By adding an `$inject` property onto a function the injection parameters can be specified.
*
* ## Inline
* As an array of injection names, where the last item in the array is the function to call.
@@ -3279,7 +3366,7 @@
* @name $injector#has
*
* @description
- * Allows the user to query if the particular service exist.
+ * Allows the user to query if the particular service exists.
*
* @param {string} Name of the service to query.
* @returns {boolean} returns true if injector has given service.
@@ -3289,8 +3376,8 @@
* @ngdoc method
* @name $injector#instantiate
* @description
- * Create a new instance of JS type. The method takes a constructor function invokes the new
- * operator and supplies all of the arguments to the constructor function as specified by the
+ * Create a new instance of JS type. The method takes a constructor function, invokes the new
+ * operator, and supplies all of the arguments to the constructor function as specified by the
* constructor annotation.
*
* @param {Function} Type Annotated constructor function.
@@ -3383,7 +3470,7 @@
/**
- * @ngdoc object
+ * @ngdoc service
* @name $provide
*
* @description
@@ -3689,7 +3776,7 @@
var INSTANTIATING = {},
providerSuffix = 'Provider',
path = [],
- loadedModules = new HashMap(),
+ loadedModules = new HashMap([], true),
providerCache = {
$provide: {
provider: supportObject(provider),
@@ -3822,7 +3909,8 @@
function getService(serviceName) {
if (cache.hasOwnProperty(serviceName)) {
if (cache[serviceName] === INSTANTIATING) {
- throw $injectorMinErr('cdep', 'Circular dependency found: {0}', path.join(' <- '));
+ throw $injectorMinErr('cdep', 'Circular dependency found: {0}',
+ serviceName + ' <- ' + path.join(' <- '));
}
return cache[serviceName];
} else {
@@ -3859,8 +3947,7 @@
: getService(key)
);
}
- if (!fn.$inject) {
- // this means that we must be an array.
+ if (isArray(fn)) {
fn = fn[length];
}
@@ -3903,7 +3990,7 @@
* @requires $rootScope
*
* @description
- * When called, it checks current value of `$location.hash()` and scroll to related element,
+ * When called, it checks current value of `$location.hash()` and scrolls to the related element,
* according to rules specified in
* [Html5 spec](http://dev.w3.org/html5/spec/Overview.html#the-indicated-part-of-the-document).
*
@@ -4105,7 +4192,7 @@
*
* @ngdoc method
* @name $animate#enter
- * @function
+ * @kind function
* @description Inserts the element into the DOM either after the `after` element or within
* the `parent` element. Once complete, the done() callback will be fired (if provided).
* @param {DOMElement} element the element which will be inserted into the DOM
@@ -4132,7 +4219,7 @@
*
* @ngdoc method
* @name $animate#leave
- * @function
+ * @kind function
* @description Removes the element from the DOM. Once complete, the done() callback will be
* fired (if provided).
* @param {DOMElement} element the element which will be removed from the DOM
@@ -4148,7 +4235,7 @@
*
* @ngdoc method
* @name $animate#move
- * @function
+ * @kind function
* @description Moves the position of the provided element within the DOM to be placed
* either after the `after` element or inside of the `parent` element. Once complete, the
* done() callback will be fired (if provided).
@@ -4172,7 +4259,7 @@
*
* @ngdoc method
* @name $animate#addClass
- * @function
+ * @kind function
* @description Adds the provided className CSS class value to the provided element. Once
* complete, the done() callback will be fired (if provided).
* @param {DOMElement} element the element which will have the className value
@@ -4195,7 +4282,7 @@
*
* @ngdoc method
* @name $animate#removeClass
- * @function
+ * @kind function
* @description Removes the provided className CSS class value from the provided element.
* Once complete, the done() callback will be fired (if provided).
* @param {DOMElement} element the element which will have the className value
@@ -4218,10 +4305,10 @@
*
* @ngdoc method
* @name $animate#setClass
- * @function
+ * @kind function
* @description Adds and/or removes the given CSS classes to and from the element.
* Once complete, the done() callback will be fired (if provided).
- * @param {DOMElement} element the element which will it's CSS classes changed
+ * @param {DOMElement} element the element which will have its CSS classes changed
* removed from it
* @param {string} add the CSS classes which will be added to the element
* @param {string} remove the CSS class which will be removed from the element
@@ -4660,17 +4747,17 @@
* @param {string} cacheId Name or id of the newly created cache.
* @param {object=} options Options object that specifies the cache behavior. Properties:
*
- * - `{number=}` `capacity` — turns the cache into LRU cache.
+ * - `{number=}` `capacity` — turns the cache into LRU cache.
*
* @returns {object} Newly created cache object with the following set of methods:
*
- * - `{object}` `info()` — Returns id, size, and options of cache.
- * - `{{*}}` `put({string} key, {*} value)` — Puts a new key-value pair into the cache and returns
+ * - `{object}` `info()` — Returns id, size, and options of cache.
+ * - `{{*}}` `put({string} key, {*} value)` — Puts a new key-value pair into the cache and returns
* it.
- * - `{{*}}` `get({string} key)` — Returns cached value for `key` or undefined for cache miss.
- * - `{void}` `remove({string} key)` — Removes a key-value pair from the cache.
- * - `{void}` `removeAll()` — Removes all cached values.
- * - `{void}` `destroy()` — Removes references to this cache from $cacheFactory.
+ * - `{{*}}` `get({string} key)` — Returns cached value for `key` or undefined for cache miss.
+ * - `{void}` `remove({string} key)` — Removes a key-value pair from the cache.
+ * - `{void}` `removeAll()` — Removes all cached values.
+ * - `{void}` `destroy()` — Removes references to this cache from $cacheFactory.
*
* @example
@@ -4775,7 +4862,7 @@
/**
* @ngdoc method
* @name $cacheFactory.Cache#put
- * @function
+ * @kind function
*
* @description
* Inserts a named entry into the {@link $cacheFactory.Cache Cache} object to be
@@ -4811,7 +4898,7 @@
/**
* @ngdoc method
* @name $cacheFactory.Cache#get
- * @function
+ * @kind function
*
* @description
* Retrieves named data stored in the {@link $cacheFactory.Cache Cache} object.
@@ -4835,7 +4922,7 @@
/**
* @ngdoc method
* @name $cacheFactory.Cache#remove
- * @function
+ * @kind function
*
* @description
* Removes an entry from the {@link $cacheFactory.Cache Cache} object.
@@ -4863,7 +4950,7 @@
/**
* @ngdoc method
* @name $cacheFactory.Cache#removeAll
- * @function
+ * @kind function
*
* @description
* Clears the cache object of any entries.
@@ -4879,7 +4966,7 @@
/**
* @ngdoc method
* @name $cacheFactory.Cache#destroy
- * @function
+ * @kind function
*
* @description
* Destroys the {@link $cacheFactory.Cache Cache} object entirely,
@@ -4896,7 +4983,7 @@
/**
* @ngdoc method
* @name $cacheFactory.Cache#info
- * @function
+ * @kind function
*
* @description
* Retrieve information regarding a particular {@link $cacheFactory.Cache Cache}.
@@ -4951,7 +5038,7 @@
* @name $cacheFactory#info
*
* @description
- * Get information about all the of the caches that have been created
+ * Get information about all the caches that have been created
*
* @returns {Object} - key-value map of `cacheId` to the result of calling `cache#info`
*/
@@ -5052,7 +5139,7 @@
/**
* @ngdoc service
* @name $compile
- * @function
+ * @kind function
*
* @description
* Compiles an HTML string or DOM into a template and produces a template function, which
@@ -5090,7 +5177,6 @@
* template: '', // or // function(tElement, tAttrs) { ... },
* // or
* // templateUrl: 'directive.html', // or // function(tElement, tAttrs) { ... },
- * replace: false,
* transclude: false,
* restrict: 'A',
* scope: false,
@@ -5194,7 +5280,7 @@
* local name. Given `` and widget definition of
* `scope: { localFn:'&myAttr' }`, then isolate scope property `localFn` will point to
* a function wrapper for the `count = count + value` expression. Often it's desirable to
- * pass data from the isolated scope via an expression and to the parent scope, this can be
+ * pass data from the isolated scope via an expression to the parent scope, this can be
* done by passing a map of local variable names and values into the expression wrapper fn.
* For example, if the expression is `increment(amount)` then we can specify the amount value
* by calling the `localFn` as `localFn({amount: 22})`.
@@ -5245,14 +5331,16 @@
*
*
* #### `template`
- * replace the current element with the contents of the HTML. The replacement process
- * migrates all of the attributes / classes from the old element to the new one. See the
- * {@link guide/directive#creating-custom-directives_creating-directives_template-expanding-directive
- * Directives Guide} for an example.
+ * HTML markup that may:
+ * * Replace the contents of the directive's element (default).
+ * * Replace the directive's element itself (if `replace` is true - DEPRECATED).
+ * * Wrap the contents of the directive's element (if `transclude` is true).
+ *
+ * Value may be:
*
- * You can specify `template` as a string representing the template or as a function which takes
- * two arguments `tElement` and `tAttrs` (described in the `compile` function api below) and
- * returns a string value representing the template.
+ * * A string. For example `
{{delete_str}}
`.
+ * * A function which takes two arguments `tElement` and `tAttrs` (described in the `compile`
+ * function api below) and returns a string value.
*
*
* #### `templateUrl`
@@ -5266,12 +5354,15 @@
* api/ng.$sce#getTrustedResourceUrl $sce.getTrustedResourceUrl}.
*
*
- * #### `replace`
- * specify where the template should be inserted. Defaults to `false`.
+ * #### `replace` ([*DEPRECATED*!], will be removed in next major release)
+ * specify what the template should replace. Defaults to `false`.
*
- * * `true` - the template will replace the current element.
- * * `false` - the template will replace the contents of the current element.
+ * * `true` - the template will replace the directive's element.
+ * * `false` - the template will replace the contents of the directive's element.
*
+ * The replacement process migrates all of the attributes / classes from the old element to the new
+ * one. See the {@link guide/directive#creating-custom-directives_creating-directives_template-expanding-directive
+ * Directives Guide} for an example.
*
* #### `transclude`
* compile the content of the element and make it available to the directive.
@@ -5285,6 +5376,11 @@
* * `true` - transclude the content of the directive.
* * `'element'` - transclude the whole element including any directives defined at lower priority.
*
+ *
+ * **Note:** When testing an element transclude directive you must not place the directive at the root of the
+ * DOM fragment that is being compiled. See {@link guide/unit-testing#testing-transclusion-directives
+ * Testing Transclusion Directives}.
+ *
*
* #### `compile`
*
@@ -5293,11 +5389,7 @@
* ```
*
* The compile function deals with transforming the template DOM. Since most directives do not do
- * template transformation, it is not used often. Examples that require compile functions are
- * directives that transform template DOM, such as {@link
- * api/ng.directive:ngRepeat ngRepeat}, or load the contents
- * asynchronously, such as {@link ngRoute.directive:ngView ngView}. The
- * compile function takes the following arguments.
+ * template transformation, it is not used often. The compile function takes the following arguments:
*
* * `tElement` - template element - The element where the directive has been declared. It is
* safe to do template transformation on the element and child elements only.
@@ -5425,10 +5517,10 @@
* to illustrate how `$compile` works.
*
*
-
+
-
+
@@ -5535,7 +5626,7 @@
/**
* @ngdoc provider
* @name $compileProvider
- * @function
+ * @kind function
*
* @description
*/
@@ -5543,8 +5634,8 @@
function $CompileProvider($provide, $$sanitizeUriProvider) {
var hasDirectives = {},
Suffix = 'Directive',
- COMMENT_DIRECTIVE_REGEXP = /^\s*directive\:\s*([\d\w\-_]+)\s+(.*)$/,
- CLASS_DIRECTIVE_REGEXP = /(([\d\w\-_]+)(?:\:([^;]+))?;?)/;
+ COMMENT_DIRECTIVE_REGEXP = /^\s*directive\:\s*([\d\w_\-]+)\s+(.*)$/,
+ CLASS_DIRECTIVE_REGEXP = /(([\d\w_\-]+)(?:\:([^;]+))?;?)/;
// Ref: http://developers.whatwg.org/webappapis.html#event-handler-idl-attributes
// The assumption is that future DOM event attribute names will begin with
@@ -5554,7 +5645,7 @@
/**
* @ngdoc method
* @name $compileProvider#directive
- * @function
+ * @kind function
*
* @description
* Register a new directive with the compiler.
@@ -5607,7 +5698,7 @@
/**
* @ngdoc method
* @name $compileProvider#aHrefSanitizationWhitelist
- * @function
+ * @kind function
*
* @description
* Retrieves or overrides the default regular expression that is used for whitelisting of safe
@@ -5637,7 +5728,7 @@
/**
* @ngdoc method
* @name $compileProvider#imgSrcSanitizationWhitelist
- * @function
+ * @kind function
*
* @description
* Retrieves or overrides the default regular expression that is used for whitelisting of safe
@@ -5681,7 +5772,7 @@
/**
* @ngdoc method
* @name $compile.directive.Attributes#$addClass
- * @function
+ * @kind function
*
* @description
* Adds the CSS class value specified by the classVal parameter to the element. If animations
@@ -5698,7 +5789,7 @@
/**
* @ngdoc method
* @name $compile.directive.Attributes#$removeClass
- * @function
+ * @kind function
*
* @description
* Removes the CSS class value specified by the classVal parameter from the element. If
@@ -5715,7 +5806,7 @@
/**
* @ngdoc method
* @name $compile.directive.Attributes#$updateClass
- * @function
+ * @kind function
*
* @description
* Adds and removes the appropriate CSS class values to the element based on the difference
@@ -5803,7 +5894,7 @@
/**
* @ngdoc method
* @name $compile.directive.Attributes#$observe
- * @function
+ * @kind function
*
* @description
* Observes an interpolated attribute.
@@ -5866,7 +5957,7 @@
compileNodes($compileNodes, transcludeFn, $compileNodes,
maxPriority, ignoreDirective, previousCompileContext);
safeAddClass($compileNodes, 'ng-scope');
- return function publicLinkFn(scope, cloneConnectFn, transcludeControllers){
+ return function publicLinkFn(scope, cloneConnectFn, transcludeControllers, parentBoundTranscludeFn){
assertArg(scope, 'scope');
// important!!: we must call our jqLite.clone() since the jQuery one is trying to be smart
// and sometimes changes the structure of the DOM.
@@ -5888,7 +5979,7 @@
}
if (cloneConnectFn) cloneConnectFn($linkNode, scope);
- if (compositeLinkFn) compositeLinkFn(scope, $linkNode, $linkNode);
+ if (compositeLinkFn) compositeLinkFn(scope, $linkNode, $linkNode, parentBoundTranscludeFn);
return $linkNode;
};
}
@@ -5935,7 +6026,7 @@
: null;
if (nodeLinkFn && nodeLinkFn.scope) {
- safeAddClass(jqLite(nodeList[i]), 'ng-scope');
+ safeAddClass(attrs.$$element, 'ng-scope');
}
childLinkFn = (nodeLinkFn && nodeLinkFn.terminal ||
@@ -5943,7 +6034,9 @@
!childNodes.length)
? null
: compileNodes(childNodes,
- nodeLinkFn ? nodeLinkFn.transclude : transcludeFn);
+ nodeLinkFn ? (
+ (nodeLinkFn.transcludeOnThisElement || !nodeLinkFn.templateOnThisElement)
+ && nodeLinkFn.transclude) : transcludeFn);
linkFns.push(nodeLinkFn, childLinkFn);
linkFnFound = linkFnFound || nodeLinkFn || childLinkFn;
@@ -5954,8 +6047,8 @@
// return a linking function if we have found anything, null otherwise
return linkFnFound ? compositeLinkFn : null;
- function compositeLinkFn(scope, nodeList, $rootElement, boundTranscludeFn) {
- var nodeLinkFn, childLinkFn, node, $node, childScope, childTranscludeFn, i, ii, n;
+ function compositeLinkFn(scope, nodeList, $rootElement, parentBoundTranscludeFn) {
+ var nodeLinkFn, childLinkFn, node, childScope, i, ii, n, childBoundTranscludeFn;
// copy nodeList so that linking doesn't break due to live list updates.
var nodeListLength = nodeList.length,
@@ -5968,32 +6061,40 @@
node = stableNodeList[n];
nodeLinkFn = linkFns[i++];
childLinkFn = linkFns[i++];
- $node = jqLite(node);
if (nodeLinkFn) {
if (nodeLinkFn.scope) {
childScope = scope.$new();
- $node.data('$scope', childScope);
+ jqLite.data(node, '$scope', childScope);
} else {
childScope = scope;
}
- childTranscludeFn = nodeLinkFn.transclude;
- if (childTranscludeFn || (!boundTranscludeFn && transcludeFn)) {
- nodeLinkFn(childLinkFn, childScope, node, $rootElement,
- createBoundTranscludeFn(scope, childTranscludeFn || transcludeFn)
- );
+
+ if ( nodeLinkFn.transcludeOnThisElement ) {
+ childBoundTranscludeFn = createBoundTranscludeFn(scope, nodeLinkFn.transclude, parentBoundTranscludeFn);
+
+ } else if (!nodeLinkFn.templateOnThisElement && parentBoundTranscludeFn) {
+ childBoundTranscludeFn = parentBoundTranscludeFn;
+
+ } else if (!parentBoundTranscludeFn && transcludeFn) {
+ childBoundTranscludeFn = createBoundTranscludeFn(scope, transcludeFn);
+
} else {
- nodeLinkFn(childLinkFn, childScope, node, $rootElement, boundTranscludeFn);
+ childBoundTranscludeFn = null;
}
+
+ nodeLinkFn(childLinkFn, childScope, node, $rootElement, childBoundTranscludeFn);
+
} else if (childLinkFn) {
- childLinkFn(scope, node.childNodes, undefined, boundTranscludeFn);
+ childLinkFn(scope, node.childNodes, undefined, parentBoundTranscludeFn);
}
}
}
}
- function createBoundTranscludeFn(scope, transcludeFn) {
- return function boundTranscludeFn(transcludedScope, cloneFn, controllers) {
+ function createBoundTranscludeFn(scope, transcludeFn, previousBoundTranscludeFn) {
+
+ var boundTranscludeFn = function(transcludedScope, cloneFn, controllers) {
var scopeCreated = false;
if (!transcludedScope) {
@@ -6002,12 +6103,14 @@
scopeCreated = true;
}
- var clone = transcludeFn(transcludedScope, cloneFn, controllers);
+ var clone = transcludeFn(transcludedScope, cloneFn, controllers, previousBoundTranscludeFn);
if (scopeCreated) {
- clone.on('$destroy', bind(transcludedScope, transcludedScope.$destroy));
+ clone.on('$destroy', function() { transcludedScope.$destroy(); });
}
return clone;
};
+
+ return boundTranscludeFn;
}
/**
@@ -6033,7 +6136,7 @@
directiveNormalize(nodeName_(node).toLowerCase()), 'E', maxPriority, ignoreDirective);
// iterate over the attributes
- for (var attr, name, nName, ngAttrName, value, nAttrs = node.attributes,
+ for (var attr, name, nName, ngAttrName, value, isNgAttr, nAttrs = node.attributes,
j = 0, jj = nAttrs && nAttrs.length; j < jj; j++) {
var attrStartName = false;
var attrEndName = false;
@@ -6041,9 +6144,11 @@
attr = nAttrs[j];
if (!msie || msie >= 8 || attr.specified) {
name = attr.name;
+ value = trim(attr.value);
+
// support ngAttr attribute binding
ngAttrName = directiveNormalize(name);
- if (NG_ATTR_BINDING.test(ngAttrName)) {
+ if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) {
name = snake_case(ngAttrName.substr(6), '-');
}
@@ -6056,9 +6161,11 @@
nName = directiveNormalize(name.toLowerCase());
attrsMap[nName] = name;
- attrs[nName] = value = trim(attr.value);
- if (getBooleanAttrName(node, nName)) {
- attrs[nName] = true; // presence means true
+ if (isNgAttr || !attrs.hasOwnProperty(nName)) {
+ attrs[nName] = value;
+ if (getBooleanAttrName(node, nName)) {
+ attrs[nName] = true; // presence means true
+ }
}
addAttrInterpolateDirective(node, directives, value, nName);
addDirective(directives, nName, 'A', maxPriority, ignoreDirective, attrStartName,
@@ -6185,6 +6292,7 @@
templateDirective = previousCompileContext.templateDirective,
nonTlbTranscludeDirective = previousCompileContext.nonTlbTranscludeDirective,
hasTranscludeDirective = false,
+ hasTemplate = false,
hasElementTranscludeDirective = previousCompileContext.hasElementTranscludeDirective,
$compileNode = templateAttrs.$$element = jqLite(compileNode),
directive,
@@ -6249,12 +6357,12 @@
if (directiveValue == 'element') {
hasElementTranscludeDirective = true;
terminalPriority = directive.priority;
- $template = groupScan(compileNode, attrStart, attrEnd);
+ $template = $compileNode;
$compileNode = templateAttrs.$$element =
jqLite(document.createComment(' ' + directiveName + ': ' +
templateAttrs[directiveName] + ' '));
compileNode = $compileNode[0];
- replaceWith(jqCollection, jqLite(sliceArgs($template)), compileNode);
+ replaceWith(jqCollection, sliceArgs($template), compileNode);
childTranscludeFn = compile($template, transcludeFn, terminalPriority,
replaceDirective && replaceDirective.name, {
@@ -6275,6 +6383,7 @@
}
if (directive.template) {
+ hasTemplate = true;
assertNoDuplicate('template', templateDirective, directive, $compileNode);
templateDirective = directive;
@@ -6289,7 +6398,7 @@
if (jqLiteIsTextNode(directiveValue)) {
$template = [];
} else {
- $template = jqLite(directiveValue);
+ $template = jqLite(trim(directiveValue));
}
compileNode = $template[0];
@@ -6324,6 +6433,7 @@
}
if (directive.templateUrl) {
+ hasTemplate = true;
assertNoDuplicate('template', templateDirective, directive, $compileNode);
templateDirective = directive;
@@ -6332,7 +6442,7 @@
}
nodeLinkFn = compileTemplateUrl(directives.splice(i, directives.length - i), $compileNode,
- templateAttrs, jqCollection, childTranscludeFn, preLinkFns, postLinkFns, {
+ templateAttrs, jqCollection, hasTranscludeDirective && childTranscludeFn, preLinkFns, postLinkFns, {
controllerDirectives: controllerDirectives,
newIsolateScopeDirective: newIsolateScopeDirective,
templateDirective: templateDirective,
@@ -6360,7 +6470,10 @@
}
nodeLinkFn.scope = newScopeDirective && newScopeDirective.scope === true;
- nodeLinkFn.transclude = hasTranscludeDirective && childTranscludeFn;
+ nodeLinkFn.transcludeOnThisElement = hasTranscludeDirective;
+ nodeLinkFn.templateOnThisElement = hasTemplate;
+ nodeLinkFn.transclude = childTranscludeFn;
+
previousCompileContext.hasElementTranscludeDirective = hasElementTranscludeDirective;
// might be normal or delayed nodeLinkFn depending on if templateUrl is present
@@ -6372,6 +6485,7 @@
if (pre) {
if (attrStart) pre = groupElementsLinkFnWrapper(pre, attrStart, attrEnd);
pre.require = directive.require;
+ pre.directiveName = directiveName;
if (newIsolateScopeDirective === directive || directive.$$isolateScope) {
pre = cloneAndAnnotateFn(pre, {isolateScope: true});
}
@@ -6380,6 +6494,7 @@
if (post) {
if (attrStart) post = groupElementsLinkFnWrapper(post, attrStart, attrEnd);
post.require = directive.require;
+ post.directiveName = directiveName;
if (newIsolateScopeDirective === directive || directive.$$isolateScope) {
post = cloneAndAnnotateFn(post, {isolateScope: true});
}
@@ -6388,7 +6503,7 @@
}
- function getControllers(require, $element, elementControllers) {
+ function getControllers(directiveName, require, $element, elementControllers) {
var value, retrievalMethod = 'data', optional = false;
if (isString(require)) {
while((value = require.charAt(0)) == '^' || value == '?') {
@@ -6414,7 +6529,7 @@
} else if (isArray(require)) {
value = [];
forEach(require, function(require) {
- value.push(getControllers(require, $element, elementControllers));
+ value.push(getControllers(directiveName, require, $element, elementControllers));
});
}
return value;
@@ -6424,28 +6539,26 @@
function nodeLinkFn(childLinkFn, scope, linkNode, $rootElement, boundTranscludeFn) {
var attrs, $element, i, ii, linkFn, controller, isolateScope, elementControllers = {}, transcludeFn;
- if (compileNode === linkNode) {
- attrs = templateAttrs;
- } else {
- attrs = shallowCopy(templateAttrs, new Attributes(jqLite(linkNode), templateAttrs.$attr));
- }
+ attrs = (compileNode === linkNode)
+ ? templateAttrs
+ : shallowCopy(templateAttrs, new Attributes(jqLite(linkNode), templateAttrs.$attr));
$element = attrs.$$element;
if (newIsolateScopeDirective) {
var LOCAL_REGEXP = /^\s*([@=&])(\??)\s*(\w*)\s*$/;
- var $linkNode = jqLite(linkNode);
isolateScope = scope.$new(true);
- if (templateDirective && (templateDirective === newIsolateScopeDirective.$$originalDirective)) {
- $linkNode.data('$isolateScope', isolateScope) ;
+ if (templateDirective && (templateDirective === newIsolateScopeDirective ||
+ templateDirective === newIsolateScopeDirective.$$originalDirective)) {
+ $element.data('$isolateScope', isolateScope);
} else {
- $linkNode.data('$isolateScopeNoTemplate', isolateScope);
+ $element.data('$isolateScopeNoTemplate', isolateScope);
}
- safeAddClass($linkNode, 'ng-isolate-scope');
+ safeAddClass($element, 'ng-isolate-scope');
forEach(newIsolateScopeDirective.scope, function(definition, scopeName) {
var match = definition.match(LOCAL_REGEXP) || [],
@@ -6479,7 +6592,7 @@
if (parentGet.literal) {
compare = equals;
} else {
- compare = function(a,b) { return a === b; };
+ compare = function(a,b) { return a === b || (a !== a && b !== b); };
}
parentSet = parentGet.assign || function() {
// reset the change, or we will throw this exception on every $digest
@@ -6557,7 +6670,7 @@
try {
linkFn = preLinkFns[i];
linkFn(linkFn.isolateScope ? isolateScope : scope, $element, attrs,
- linkFn.require && getControllers(linkFn.require, $element, elementControllers), transcludeFn);
+ linkFn.require && getControllers(linkFn.directiveName, linkFn.require, $element, elementControllers), transcludeFn);
} catch (e) {
$exceptionHandler(e, startingTag($element));
}
@@ -6577,7 +6690,7 @@
try {
linkFn = postLinkFns[i];
linkFn(linkFn.isolateScope ? isolateScope : scope, $element, attrs,
- linkFn.require && getControllers(linkFn.require, $element, elementControllers), transcludeFn);
+ linkFn.require && getControllers(linkFn.directiveName, linkFn.require, $element, elementControllers), transcludeFn);
} catch (e) {
$exceptionHandler(e, startingTag($element));
}
@@ -6663,7 +6776,7 @@
// reapply the old attributes to the new element
forEach(dst, function(value, key) {
if (key.charAt(0) != '$') {
- if (src[key]) {
+ if (src[key] && src[key] !== value) {
value += (key === 'style' ? ';' : ' ') + src[key];
}
dst.$set(key, value, true, srcAttr[key]);
@@ -6716,7 +6829,7 @@
if (jqLiteIsTextNode(content)) {
$template = [];
} else {
- $template = jqLite(content);
+ $template = jqLite(trim(content));
}
compileNode = $template[0];
@@ -6752,7 +6865,6 @@
});
afterTemplateChildLinkFn = compileNodes($compileNode[0].childNodes, childTranscludeFn);
-
while(linkQueue.length) {
var scope = linkQueue.shift(),
beforeTemplateLinkNode = linkQueue.shift(),
@@ -6774,8 +6886,8 @@
// Copy in CSS classes from original node
safeAddClass(jqLite(linkNode), oldClasses);
}
- if (afterTemplateNodeLinkFn.transclude) {
- childBoundTranscludeFn = createBoundTranscludeFn(scope, afterTemplateNodeLinkFn.transclude);
+ if (afterTemplateNodeLinkFn.transcludeOnThisElement) {
+ childBoundTranscludeFn = createBoundTranscludeFn(scope, afterTemplateNodeLinkFn.transclude, boundTranscludeFn);
} else {
childBoundTranscludeFn = boundTranscludeFn;
}
@@ -6789,13 +6901,17 @@
});
return function delayedNodeLinkFn(ignoreChildLinkFn, scope, node, rootElement, boundTranscludeFn) {
+ var childBoundTranscludeFn = boundTranscludeFn;
if (linkQueue) {
linkQueue.push(scope);
linkQueue.push(node);
linkQueue.push(rootElement);
- linkQueue.push(boundTranscludeFn);
+ linkQueue.push(childBoundTranscludeFn);
} else {
- afterTemplateNodeLinkFn(afterTemplateChildLinkFn, scope, node, rootElement, boundTranscludeFn);
+ if (afterTemplateNodeLinkFn.transcludeOnThisElement) {
+ childBoundTranscludeFn = createBoundTranscludeFn(scope, afterTemplateNodeLinkFn.transclude, boundTranscludeFn);
+ }
+ afterTemplateNodeLinkFn(afterTemplateChildLinkFn, scope, node, rootElement, childBoundTranscludeFn);
}
};
}
@@ -6825,15 +6941,23 @@
if (interpolateFn) {
directives.push({
priority: 0,
- compile: valueFn(function textInterpolateLinkFn(scope, node) {
- var parent = node.parent(),
- bindings = parent.data('$binding') || [];
- bindings.push(interpolateFn);
- safeAddClass(parent.data('$binding', bindings), 'ng-binding');
- scope.$watch(interpolateFn, function interpolateFnWatchAction(value) {
- node[0].nodeValue = value;
- });
- })
+ compile: function textInterpolateCompileFn(templateNode) {
+ // when transcluding a template that has bindings in the root
+ // then we don't have a parent and should do this in the linkFn
+ var parent = templateNode.parent(), hasCompileParent = parent.length;
+ if (hasCompileParent) safeAddClass(templateNode.parent(), 'ng-binding');
+
+ return function textInterpolateLinkFn(scope, node) {
+ var parent = node.parent(),
+ bindings = parent.data('$binding') || [];
+ bindings.push(interpolateFn);
+ parent.data('$binding', bindings);
+ if (!hasCompileParent) safeAddClass(parent, 'ng-binding');
+ scope.$watch(interpolateFn, function interpolateFnWatchAction(value) {
+ node[0].nodeValue = value;
+ });
+ };
+ }
});
}
}
@@ -6997,7 +7121,9 @@
* element attributes. The values reflect current binding state `{{ }}`. The normalization is
* needed since all of these are treated as equivalent in Angular:
*
+ * ```
*
+ * ```
*/
/**
@@ -7011,7 +7137,7 @@
/**
* @ngdoc method
* @name $compile.directive.Attributes#$set
- * @function
+ * @kind function
*
* @description
* Set DOM element attribute value.
@@ -7134,7 +7260,7 @@
instance = $injector.instantiate(expression, locals);
if (identifier) {
- if (!(locals && typeof locals.$scope == 'object')) {
+ if (!(locals && typeof locals.$scope === 'object')) {
throw minErr('$controller')('noscp',
"Cannot export controller '{0}' as '{1}'! No $scope object provided via `locals`.",
constructor || expression.name, identifier);
@@ -7157,18 +7283,19 @@
* A {@link angular.element jQuery or jqLite} wrapper for the browser's `window.document` object.
*
* @example
-
+
-
+
$document title:
window.document title:
- function MainCtrl($scope, $document) {
- $scope.title = $document[0].title;
- $scope.windowTitle = angular.element(window.document)[0].title;
- }
+ angular.module('documentExample', [])
+ .controller('ExampleController', ['$scope', '$document', function($scope, $document) {
+ $scope.title = $document[0].title;
+ $scope.windowTitle = angular.element(window.document)[0].title;
+ }]);
*/
@@ -7235,11 +7362,7 @@
val = trim(line.substr(i + 1));
if (key) {
- if (parsed[key]) {
- parsed[key] += ', ' + val;
- } else {
- parsed[key] = val;
- }
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
}
});
@@ -7301,12 +7424,39 @@
}
+ /**
+ * @ngdoc provider
+ * @name $httpProvider
+ * @description
+ * Use `$httpProvider` to change the default behavior of the {@link ng.$http $http} service.
+ * */
function $HttpProvider() {
var JSON_START = /^\s*(\[|\{[^\{])/,
JSON_END = /[\}\]]\s*$/,
PROTECTION_PREFIX = /^\)\]\}',?\n/,
CONTENT_TYPE_APPLICATION_JSON = {'Content-Type': 'application/json;charset=utf-8'};
+ /**
+ * @ngdoc property
+ * @name $httpProvider#defaults
+ * @description
+ *
+ * Object containing default values for all {@link ng.$http $http} requests.
+ *
+ * - **`defaults.xsrfCookieName`** - {string} - Name of cookie containing the XSRF token.
+ * Defaults value is `'XSRF-TOKEN'`.
+ *
+ * - **`defaults.xsrfHeaderName`** - {string} - Name of HTTP header to populate with the
+ * XSRF token. Defaults value is `'X-XSRF-TOKEN'`.
+ *
+ * - **`defaults.headers`** - {Object} - Default headers for all $http requests.
+ * Refer to {@link ng.$http#setting-http-headers $http} for documentation on
+ * setting default headers.
+ * - **`defaults.headers.common`**
+ * - **`defaults.headers.post`**
+ * - **`defaults.headers.put`**
+ * - **`defaults.headers.patch`**
+ **/
var defaults = this.defaults = {
// transform incoming response data
transformResponse: [function(data) {
@@ -7329,9 +7479,9 @@
common: {
'Accept': 'application/json, text/plain, */*'
},
- post: copy(CONTENT_TYPE_APPLICATION_JSON),
- put: copy(CONTENT_TYPE_APPLICATION_JSON),
- patch: copy(CONTENT_TYPE_APPLICATION_JSON)
+ post: shallowCopy(CONTENT_TYPE_APPLICATION_JSON),
+ put: shallowCopy(CONTENT_TYPE_APPLICATION_JSON),
+ patch: shallowCopy(CONTENT_TYPE_APPLICATION_JSON)
},
xsrfCookieName: 'XSRF-TOKEN',
@@ -7415,7 +7565,7 @@
*
*
* # General usage
- * The `$http` service is a function which takes a single argument — a configuration object —
+ * The `$http` service is a function which takes a single argument — a configuration object —
* that is used to generate an HTTP request and returns a {@link ng.$q promise}
* with two $http specific methods: `success` and `error`.
*
@@ -7432,7 +7582,7 @@
* ```
*
* Since the returned value of calling the $http function is a `promise`, you can also use
- * the `then` method to register callbacks, and these callbacks will receive a single argument –
+ * the `then` method to register callbacks, and these callbacks will receive a single argument –
* an object representing the response. See the API signature and type info below for more
* details.
*
@@ -7470,6 +7620,7 @@
* - {@link ng.$http#put $http.put}
* - {@link ng.$http#delete $http.delete}
* - {@link ng.$http#jsonp $http.jsonp}
+ * - {@link ng.$http#patch $http.patch}
*
*
* # Setting HTTP Headers
@@ -7573,14 +7724,14 @@
*
* There are two kinds of interceptors (and two kinds of rejection interceptors):
*
- * * `request`: interceptors get called with http `config` object. The function is free to
- * modify the `config` or create a new one. The function needs to return the `config`
- * directly or as a promise.
+ * * `request`: interceptors get called with a http `config` object. The function is free to
+ * modify the `config` object or create a new one. The function needs to return the `config`
+ * object directly, or a promise containing the `config` or a new `config` object.
* * `requestError`: interceptor gets called when a previous interceptor threw an error or
* resolved with a rejection.
* * `response`: interceptors get called with http `response` object. The function is free to
- * modify the `response` or create a new one. The function needs to return the `response`
- * directly or as a promise.
+ * modify the `response` object or create a new one. The function needs to return the `response`
+ * object directly, or as a promise containing the `response` or a new `response` object.
* * `responseError`: interceptor gets called when a previous interceptor threw an error or
* resolved with a rejection.
*
@@ -7592,7 +7743,7 @@
* // optional method
* 'request': function(config) {
* // do something on success
- * return config || $q.when(config);
+ * return config;
* },
*
* // optional method
@@ -7609,7 +7760,7 @@
* // optional method
* 'response': function(response) {
* // do something on success
- * return response || $q.when(response);
+ * return response;
* },
*
* // optional method
@@ -7653,7 +7804,7 @@
*
* The interceptors are service factories that are registered with the $httpProvider by
* adding them to the `$httpProvider.responseInterceptors` array. The factory is called and
- * injected with dependencies (if specified) and returns the interceptor — a function that
+ * injected with dependencies (if specified) and returns the interceptor — a function that
* takes a {@link ng.$q promise} and returns the original or a new promise.
*
* ```js
@@ -7745,33 +7896,33 @@
* @param {object} config Object describing the request to be made and how it should be
* processed. The object has following properties:
*
- * - **method** – `{string}` – HTTP method (e.g. 'GET', 'POST', etc)
- * - **url** – `{string}` – Absolute or relative URL of the resource that is being requested.
- * - **params** – `{Object.}` – Map of strings or objects which will be turned
+ * - **method** – `{string}` – HTTP method (e.g. 'GET', 'POST', etc)
+ * - **url** – `{string}` – Absolute or relative URL of the resource that is being requested.
+ * - **params** – `{Object.}` – Map of strings or objects which will be turned
* to `?key1=value1&key2=value2` after the url. If the value is not a string, it will be
* JSONified.
- * - **data** – `{string|Object}` – Data to be sent as the request message data.
- * - **headers** – `{Object}` – Map of strings or functions which return strings representing
+ * - **data** – `{string|Object}` – Data to be sent as the request message data.
+ * - **headers** – `{Object}` – Map of strings or functions which return strings representing
* HTTP headers to send to the server. If the return value of a function is null, the
* header will not be sent.
- * - **xsrfHeaderName** – `{string}` – Name of HTTP header to populate with the XSRF token.
- * - **xsrfCookieName** – `{string}` – Name of cookie containing the XSRF token.
- * - **transformRequest** –
- * `{function(data, headersGetter)|Array.}` –
+ * - **xsrfHeaderName** – `{string}` – Name of HTTP header to populate with the XSRF token.
+ * - **xsrfCookieName** – `{string}` – Name of cookie containing the XSRF token.
+ * - **transformRequest** –
+ * `{function(data, headersGetter)|Array.}` –
* transform function or an array of such functions. The transform function takes the http
* request body and headers and returns its transformed (typically serialized) version.
- * - **transformResponse** –
- * `{function(data, headersGetter)|Array.}` –
+ * - **transformResponse** –
+ * `{function(data, headersGetter)|Array.}` –
* transform function or an array of such functions. The transform function takes the http
* response body and headers and returns its transformed (typically deserialized) version.
- * - **cache** – `{boolean|Cache}` – If true, a default $http cache will be used to cache the
+ * - **cache** – `{boolean|Cache}` – If true, a default $http cache will be used to cache the
* GET request, otherwise if a cache instance built with
* {@link ng.$cacheFactory $cacheFactory}, this cache will be used for
* caching.
- * - **timeout** – `{number|Promise}` – timeout in milliseconds, or {@link ng.$q promise}
+ * - **timeout** – `{number|Promise}` – timeout in milliseconds, or {@link ng.$q promise}
* that should abort the request when resolved.
- * - **withCredentials** - `{boolean}` - whether to to set the `withCredentials` flag on the
- * XHR object. See [requests with credentials]https://developer.mozilla.org/en/http_access_control#section_5
+ * - **withCredentials** - `{boolean}` - whether to set the `withCredentials` flag on the
+ * XHR object. See [requests with credentials](https://developer.mozilla.org/docs/Web/HTTP/Access_control_CORS#Requests_with_credentials)
* for more information.
* - **responseType** - `{string}` - see
* [requestType](https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#responseType).
@@ -7784,21 +7935,21 @@
* these functions are destructured representation of the response object passed into the
* `then` method. The response object has these properties:
*
- * - **data** – `{string|Object}` – The response body transformed with the transform
+ * - **data** – `{string|Object}` – The response body transformed with the transform
* functions.
- * - **status** – `{number}` – HTTP status code of the response.
- * - **headers** – `{function([headerName])}` – Header getter function.
- * - **config** – `{Object}` – The configuration object that was used to generate the request.
- * - **statusText** – `{string}` – HTTP status text of the response.
+ * - **status** – `{number}` – HTTP status code of the response.
+ * - **headers** – `{function([headerName])}` – Header getter function.
+ * - **config** – `{Object}` – The configuration object that was used to generate the request.
+ * - **statusText** – `{string}` – HTTP status text of the response.
*
* @property {Array.