polyfills.ts 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /**
  2. * This file includes polyfills needed by Angular and is loaded before the app.
  3. * You can add your own extra polyfills to this file.
  4. *
  5. * This file is divided into 2 sections:
  6. * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
  7. * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
  8. * file.
  9. *
  10. * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
  11. * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
  12. * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
  13. *
  14. * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
  15. */
  16. /***************************************************************************************************
  17. * BROWSER POLYFILLS
  18. */
  19. /** IE9, IE10 and IE11 requires all of the following polyfills. **/
  20. import 'core-js/es6/symbol';
  21. import 'core-js/es6/object';
  22. import 'core-js/es6/function';
  23. import 'core-js/es6/parse-int';
  24. import 'core-js/es6/parse-float';
  25. import 'core-js/es6/number';
  26. import 'core-js/es6/math';
  27. import 'core-js/es6/string';
  28. import 'core-js/es6/date';
  29. import 'core-js/es6/array';
  30. import 'core-js/es6/regexp';
  31. import 'core-js/es6/map';
  32. import 'core-js/es6/weak-map';
  33. import 'core-js/es6/set';
  34. /** IE10 and IE11 requires the following for NgClass support on SVG elements */
  35. // import 'classlist.js'; // Run `npm install --save classlist.js`.
  36. /** IE10 and IE11 requires the following for the Reflect API. */
  37. import 'core-js/es6/reflect';
  38. /** Evergreen browsers require these. **/
  39. // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
  40. import 'core-js/es7/reflect';
  41. /**
  42. * Required to support Web Animations `@angular/platform-browser/animations`.
  43. * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
  44. **/
  45. // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
  46. /**
  47. * By default, zone.js will patch all possible macroTask and DomEvents
  48. * user can disable parts of macroTask/DomEvents patch by setting following flags
  49. */
  50. // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
  51. // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
  52. // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
  53. /*
  54. * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
  55. * with the following flag, it will bypass `zone.js` patch for IE/Edge
  56. */
  57. // (window as any).__Zone_enable_cross_context_check = true;
  58. /***************************************************************************************************
  59. * Zone JS is required by default for Angular itself.
  60. */
  61. import 'zone.js/dist/zone'; // Included with Angular CLI.
  62. /***************************************************************************************************
  63. * APPLICATION IMPORTS
  64. */
  65. if (!String.prototype.startsWith) {
  66. String.prototype.startsWith = function(search, pos) {
  67. return this.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
  68. };
  69. }
  70. if (!Array.prototype.find) {
  71. Object.defineProperty(Array.prototype, 'find', {
  72. value: function(predicate) {
  73. // 1. Let O be ? ToObject(this value).
  74. if (this == null) {
  75. throw new TypeError('"this" is null or not defined');
  76. }
  77. var o = Object(this);
  78. // 2. Let len be ? ToLength(? Get(O, "length")).
  79. var len = o.length >>> 0;
  80. // 3. If IsCallable(predicate) is false, throw a TypeError exception.
  81. if (typeof predicate !== 'function') {
  82. throw new TypeError('predicate must be a function');
  83. }
  84. // 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
  85. var thisArg = arguments[1];
  86. // 5. Let k be 0.
  87. var k = 0;
  88. // 6. Repeat, while k < len
  89. while (k < len) {
  90. // a. Let Pk be ! ToString(k).
  91. // b. Let kValue be ? Get(O, Pk).
  92. // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
  93. // d. If testResult is true, return kValue.
  94. var kValue = o[k];
  95. if (predicate.call(thisArg, kValue, k, o)) {
  96. return kValue;
  97. }
  98. // e. Increase k by 1.
  99. k++;
  100. }
  101. // 7. Return undefined.
  102. return undefined;
  103. }
  104. });
  105. }