36496 lines · 1.3 MB · JavaScript
RawDownload
/** * @license AngularJS v1.8.0 * (c) 2010-2020 Google, Inc. http://angularjs.org * License: MIT */(function(window) {'use strict'; /* exported  minErrConfig,  errorHandlingConfig,  isValidObjectMaxDepth*/ var minErrConfig = {  objectMaxDepth: 5,  urlErrorParamsEnabled: true}; /** * @ngdoc function * @name angular.errorHandlingConfig * @module ng * @kind function * * @description * Configure several aspects of error handling in AngularJS if used as a setter or return the * current configuration if used as a getter. The following options are supported: * * - **objectMaxDepth**: The maximum depth to which objects are traversed when stringified for error messages. * * Omitted or undefined options will leave the corresponding configuration values unchanged. * * @param {Object=} config - The configuration object. May only contain the options that need to be *     updated. Supported keys: * * * `objectMaxDepth`  **{Number}** - The max depth for stringifying objects. Setting to a *   non-positive or non-numeric value, removes the max depth limit. *   Default: 5 * * * `urlErrorParamsEnabled`  **{Boolean}** - Specifies whether the generated error url will *   contain the parameters of the thrown error. Disabling the parameters can be useful if the *   generated error url is very long. * *   Default: true. When used without argument, it returns the current value. */function errorHandlingConfig(config) {  if (isObject(config)) {    if (isDefined(config.objectMaxDepth)) {      minErrConfig.objectMaxDepth = isValidObjectMaxDepth(config.objectMaxDepth) ? config.objectMaxDepth : NaN;    }    if (isDefined(config.urlErrorParamsEnabled) && isBoolean(config.urlErrorParamsEnabled)) {      minErrConfig.urlErrorParamsEnabled = config.urlErrorParamsEnabled;    }  } else {    return minErrConfig;  }} /** * @private * @param {Number} maxDepth * @return {boolean} */function isValidObjectMaxDepth(maxDepth) {  return isNumber(maxDepth) && maxDepth > 0;}  /** * @description * * This object provides a utility for producing rich Error messages within * AngularJS. It can be called as follows: * * var exampleMinErr = minErr('example'); * throw exampleMinErr('one', 'This {0} is {1}', foo, bar); * * The above creates an instance of minErr in the example namespace. The * resulting error will have a namespaced error code of example.one.  The * resulting error will replace {0} with the value of foo, and {1} with the * value of bar. The object is not restricted in the number of arguments it can * take. * * If fewer arguments are specified than necessary for interpolation, the extra * interpolation markers will be preserved in the final string. * * Since data will be parsed statically during a build step, some restrictions * are applied with respect to how minErr instances are created and called. * Instances should have names of the form namespaceMinErr for a minErr created * using minErr('namespace'). Error codes, namespaces and template strings * should all be static strings, not variables or general expressions. * * @param {string} module The namespace to use for the new minErr instance. * @param {function} ErrorConstructor Custom error constructor to be instantiated when returning *   error from returned function, for cases when a particular type of error is useful. * @returns {function(code:string, template:string, ...templateArgs): Error} minErr instance */ function minErr(module, ErrorConstructor) {  ErrorConstructor = ErrorConstructor || Error;   var url = 'https://errors.angularjs.org/1.8.0/';  var regex = url.replace('.', '\\.') + '[\\s\\S]*';  var errRegExp = new RegExp(regex, 'g');   return function() {    var code = arguments[0],      template = arguments[1],      message = '[' + (module ? module + ':' : '') + code + '] ',      templateArgs = sliceArgs(arguments, 2).map(function(arg) {        return toDebugString(arg, minErrConfig.objectMaxDepth);      }),      paramPrefix, i;     // A minErr message has two parts: the message itself and the url that contains the    // encoded message.    // The message's parameters can contain other error messages which also include error urls.    // To prevent the messages from getting too long, we strip the error urls from the parameters.     message += template.replace(/\{\d+\}/g, function(match) {      var index = +match.slice(1, -1);       if (index < templateArgs.length) {        return templateArgs[index].replace(errRegExp, '');      }       return match;    });     message += '\n' + url + (module ? module + '/' : '') + code;     if (minErrConfig.urlErrorParamsEnabled) {      for (i = 0, paramPrefix = '?'; i < templateArgs.length; i++, paramPrefix = '&') {        message += paramPrefix + 'p' + i + '=' + encodeURIComponent(templateArgs[i]);      }    }     return new ErrorConstructor(message);  };} /* We need to tell ESLint what variables are being exported *//* exported  angular,  msie,  jqLite,  jQuery,  slice,  splice,  push,  toString,  minErrConfig,  errorHandlingConfig,  isValidObjectMaxDepth,  ngMinErr,  angularModule,  uid,  REGEX_STRING_REGEXP,  VALIDITY_STATE_PROPERTY,   lowercase,  uppercase,  nodeName_,  isArrayLike,  forEach,  forEachSorted,  reverseParams,  nextUid,  setHashKey,  extend,  toInt,  inherit,  merge,  noop,  identity,  valueFn,  isUndefined,  isDefined,  isObject,  isBlankObject,  isString,  isNumber,  isNumberNaN,  isDate,  isError,  isArray,  isFunction,  isRegExp,  isWindow,  isScope,  isFile,  isFormData,  isBlob,  isBoolean,  isPromiseLike,  trim,  escapeForRegexp,  isElement,  makeMap,  includes,  arrayRemove,  copy,  simpleCompare,  equals,  csp,  jq,  concat,  sliceArgs,  bind,  toJsonReplacer,  toJson,  fromJson,  convertTimezoneToLocal,  timezoneToOffset,  addDateMinutes,  startingTag,  tryDecodeURIComponent,  parseKeyValue,  toKeyValue,  encodeUriSegment,  encodeUriQuery,  angularInit,  bootstrap,  getTestability,  snake_case,  bindJQuery,  assertArg,  assertArgFn,  assertNotHasOwnProperty,  getter,  getBlockNodes,  hasOwnProperty,  createMap,  stringify,  UNSAFE_restoreLegacyJqLiteXHTMLReplacement,   NODE_TYPE_ELEMENT,  NODE_TYPE_ATTRIBUTE,  NODE_TYPE_TEXT,  NODE_TYPE_COMMENT,  NODE_TYPE_DOCUMENT,  NODE_TYPE_DOCUMENT_FRAGMENT*/ //////////////////////////////////// /** * @ngdoc module * @name ng * @module ng * @installation * @description * * The ng module is loaded by default when an AngularJS application is started. The module itself * contains the essential components for an AngularJS application to function. The table below * lists a high level breakdown of each of the services/factories, filters, directives and testing * components available within this core module. * */ var REGEX_STRING_REGEXP = /^\/(.+)\/([a-z]*)$/; // 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';  var hasOwnProperty = Object.prototype.hasOwnProperty; /** * @private * * @description Converts the specified string to lowercase. * @param {string} string String to be converted to lowercase. * @returns {string} Lowercased string. */var lowercase = function(string) {return isString(string) ? string.toLowerCase() : string;}; /** * @private * * @description Converts the specified string to uppercase. * @param {string} string String to be converted to uppercase. * @returns {string} Uppercased string. */var uppercase = function(string) {return isString(string) ? string.toUpperCase() : string;};  var    msie,             // holds major version number for IE, or NaN if UA is not IE.    jqLite,           // delay binding since jQuery could be loaded after us.    jQuery,           // delay binding    slice             = [].slice,    splice            = [].splice,    push              = [].push,    toString          = Object.prototype.toString,    getPrototypeOf    = Object.getPrototypeOf,    ngMinErr          = minErr('ng'),     /** @name angular */    angular           = window.angular || (window.angular = {}),    angularModule,    uid               = 0; // Support: IE 9-11 only/** * documentMode is an IE-only property * http://msdn.microsoft.com/en-us/library/ie/cc196988(v=vs.85).aspx */msie = window.document.documentMode;  /** * @private * @param {*} obj * @return {boolean} Returns true if `obj` is an array or array-like object (NodeList, Arguments, *                   String ...) */function isArrayLike(obj) {   // `null`, `undefined` and `window` are not array-like  if (obj == null || isWindow(obj)) return false;   // arrays, strings and jQuery/jqLite objects are array like  // * jqLite is either the jQuery or jqLite constructor function  // * we have to check the existence of jqLite first as this method is called  //   via the forEach method when constructing the jqLite object in the first place  if (isArray(obj) || isString(obj) || (jqLite && obj instanceof jqLite)) return true;   // Support: iOS 8.2 (not reproducible in simulator)  // "length" in obj used to prevent JIT error (gh-11508)  var length = 'length' in Object(obj) && obj.length;   // NodeList objects (with `item` method) and  // other objects with suitable length characteristics are array-like  return isNumber(length) && (length >= 0 && (length - 1) in obj || typeof obj.item === 'function'); } /** * @ngdoc function * @name angular.forEach * @module ng * @kind function * * @description * Invokes the `iterator` function once for each item in `obj` collection, which can be either an * object or an array. The `iterator` function is invoked with `iterator(value, key, obj)`, where `value` * is the value of an object property or an array element, `key` is the object property key or * array element index and obj is the `obj` itself. Specifying a `context` for the function is optional. * * It is worth noting that `.forEach` does not iterate over inherited properties because it filters * using the `hasOwnProperty` method. * * Unlike ES262's * [Array.prototype.forEach](http://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.18), * providing 'undefined' or 'null' values for `obj` will not throw a TypeError, but rather just * return the value provided. *   ```js     var values = {name: 'misko', gender: 'male'};     var log = [];     angular.forEach(values, function(value, key) {       this.push(key + ': ' + value);     }, log);     expect(log).toEqual(['name: misko', 'gender: male']);   ``` * * @param {Object|Array} obj Object to iterate over. * @param {Function} iterator Iterator function. * @param {Object=} context Object to become context (`this`) for the iterator function. * @returns {Object|Array} Reference to `obj`. */ function forEach(obj, iterator, context) {  var key, length;  if (obj) {    if (isFunction(obj)) {      for (key in obj) {        if (key !== 'prototype' && key !== 'length' && key !== 'name' && obj.hasOwnProperty(key)) {          iterator.call(context, obj[key], key, obj);        }      }    } else if (isArray(obj) || isArrayLike(obj)) {      var isPrimitive = typeof obj !== 'object';      for (key = 0, length = obj.length; key < length; key++) {        if (isPrimitive || key in obj) {          iterator.call(context, obj[key], key, obj);        }      }    } else if (obj.forEach && obj.forEach !== forEach) {        obj.forEach(iterator, context, obj);    } else if (isBlankObject(obj)) {      // createMap() fast path --- Safe to avoid hasOwnProperty check because prototype chain is empty      for (key in obj) {        iterator.call(context, obj[key], key, obj);      }    } else if (typeof obj.hasOwnProperty === 'function') {      // Slow path for objects inheriting Object.prototype, hasOwnProperty check needed      for (key in obj) {        if (obj.hasOwnProperty(key)) {          iterator.call(context, obj[key], key, obj);        }      }    } else {      // Slow path for objects which do not have a method `hasOwnProperty`      for (key in obj) {        if (hasOwnProperty.call(obj, key)) {          iterator.call(context, obj[key], key, obj);        }      }    }  }  return obj;} function forEachSorted(obj, iterator, context) {  var keys = Object.keys(obj).sort();  for (var i = 0; i < keys.length; i++) {    iterator.call(context, obj[keys[i]], keys[i]);  }  return keys;}  /** * when using forEach the params are value, key, but it is often useful to have key, value. * @param {function(string, *)} iteratorFn * @returns {function(*, string)} */function reverseParams(iteratorFn) {  return function(value, key) {iteratorFn(key, value);};} /** * A consistent way of creating unique IDs in angular. * * Using simple numbers allows us to generate 28.6 million unique ids per second for 10 years before * we hit number precision issues in JavaScript. * * Math.pow(2,53) / 60 / 60 / 24 / 365 / 10 = 28.6M * * @returns {number} an unique alpha-numeric string */function nextUid() {  return ++uid;}  /** * Set or clear the hashkey for an object. * @param obj object * @param h the hashkey (!truthy to delete the hashkey) */function setHashKey(obj, h) {  if (h) {    obj.$$hashKey = h;  } else {    delete obj.$$hashKey;  }}  function baseExtend(dst, objs, deep) {  var h = dst.$$hashKey;   for (var i = 0, ii = objs.length; i < ii; ++i) {    var obj = objs[i];    if (!isObject(obj) && !isFunction(obj)) continue;    var keys = Object.keys(obj);    for (var j = 0, jj = keys.length; j < jj; j++) {      var key = keys[j];      var src = obj[key];       if (deep && isObject(src)) {        if (isDate(src)) {          dst[key] = new Date(src.valueOf());        } else if (isRegExp(src)) {          dst[key] = new RegExp(src);        } else if (src.nodeName) {          dst[key] = src.cloneNode(true);        } else if (isElement(src)) {          dst[key] = src.clone();        } else {          if (key !== '__proto__') {            if (!isObject(dst[key])) dst[key] = isArray(src) ? [] : {};            baseExtend(dst[key], [src], true);          }        }      } else {        dst[key] = src;      }    }  }   setHashKey(dst, h);  return dst;} /**

Lines 1–500 of 36496.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t