polyfills.ts 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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/guide/browser-support
  15. */
  16. // Array.prototype.includes()兼容问题,2021年7月21日-seimin
  17. if (!Array.prototype.includes) {
  18. Object.defineProperty(Array.prototype, "includes", {
  19. value: function (valueToFind, fromIndex) {
  20. if (this == null) {
  21. throw new TypeError('"this" is null or not defined');
  22. }
  23. // 1. Let O be ? ToObject(this value).
  24. var o = Object(this);
  25. // 2. Let len be ? ToLength(? Get(O, "length")).
  26. var len = o.length >>> 0;
  27. // 3. If len is 0, return false.
  28. if (len === 0) {
  29. return false;
  30. }
  31. // 4. Let n be ? ToInteger(fromIndex).
  32. // (If fromIndex is undefined, this step produces the value 0.)
  33. var n = fromIndex | 0;
  34. // 5. If n ≥ 0, then
  35. // a. Let k be n.
  36. // 6. Else n < 0,
  37. // a. Let k be len + n.
  38. // b. If k < 0, let k be 0.
  39. var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
  40. function sameValueZero(x, y) {
  41. return (
  42. x === y ||
  43. (typeof x === "number" &&
  44. typeof y === "number" &&
  45. isNaN(x) &&
  46. isNaN(y))
  47. );
  48. }
  49. // 7. Repeat, while k < len
  50. while (k < len) {
  51. // a. Let elementK be the result of ? Get(O, ! ToString(k)).
  52. // b. If SameValueZero(valueToFind, elementK) is true, return true.
  53. if (sameValueZero(o[k], valueToFind)) {
  54. return true;
  55. }
  56. // c. Increase k by 1.
  57. k++;
  58. }
  59. // 8. Return false
  60. return false;
  61. },
  62. });
  63. }
  64. // (function () {
  65. // Object.setPrototypeOf = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array ? setProtoOf : mixinProperties);
  66. // function setProtoOf(obj, proto) {
  67. // obj.__proto__ = proto;
  68. // return obj;
  69. // }
  70. // function mixinProperties(obj, proto) {
  71. // for (const prop in proto) {
  72. // if (!obj.hasOwnProperty(prop)) {
  73. // obj[prop] = proto[prop];
  74. // }
  75. // }
  76. // return obj;
  77. // }
  78. // })();
  79. // // This polyfill adds compatibility to all Browsers supporting ES5:
  80. // if ((window as any).NodeList && !NodeList.prototype.forEach) {
  81. // NodeList.prototype.forEach = function (callback, thisArg) {
  82. // thisArg = thisArg || window;
  83. // for (let i = 0; i < this.length; i++) {
  84. // callback.call(thisArg, this[i], i, this);
  85. // }
  86. // };
  87. // }
  88. // // 解决ie下报错 对象不支持matches
  89. // if (!Element.prototype.matches) {
  90. // Element.prototype.matches =
  91. // (Element.prototype as any).matchesSelector ||
  92. // (Element.prototype as any).mozMatchesSelector ||
  93. // (Element.prototype as any).msMatchesSelector ||
  94. // (Element.prototype as any).oMatchesSelector ||
  95. // Element.prototype.webkitMatchesSelector ||
  96. // function (s) {
  97. // const matches = (this.document || this.ownerDocument).querySelectorAll(s);
  98. // let i = matches.length;
  99. // while (--i >= 0 && matches.item(i) !== this) { }
  100. // return i > -1;
  101. // };
  102. // }
  103. // if (!('classList' in document.documentElement)) {
  104. // Object.defineProperty(HTMLElement.prototype, 'classList', {
  105. // get: function () {
  106. // var self = this;
  107. // function update(fn) {
  108. // return function (value) {
  109. // var classes = self.className.split(/\s+/g);
  110. // var index = classes.indexOf(value);
  111. // fn(classes, index, value);
  112. // self.className = classes.join(' ');
  113. // };
  114. // }
  115. // return {
  116. // add: update(function (classes, index, value) {
  117. // if (!~index) classes.push(value);
  118. // }),
  119. // remove: update(function (classes, index) {
  120. // if (~index) classes.splice(index, 1);
  121. // }),
  122. // toggle: update(function (classes, index, value) {
  123. // if (~index) { classes.splice(index, 1); } else { classes.push(value); }
  124. // }),
  125. // contains: function (value) {
  126. // return !!~self.className.split(/\s+/g).indexOf(value);
  127. // },
  128. // item: function (i) {
  129. // return self.className.split(/\s+/g)[i] || null;
  130. // },
  131. // };
  132. // },
  133. // });
  134. // }
  135. /***************************************************************************************************
  136. * BROWSER POLYFILLS
  137. */
  138. // import 'core-js/es/symbol';
  139. // import 'core-js/es/object';
  140. // import 'core-js/es/function';
  141. // import 'core-js/es/parse-int';
  142. // import 'core-js/es/parse-float';
  143. // import 'core-js/es/number';
  144. // import 'core-js/es/math';
  145. // import 'core-js/es/string';
  146. // import 'core-js/es/date';
  147. // import 'core-js/es/array';
  148. // import 'core-js/es/regexp';
  149. // import 'core-js/es/map';
  150. // import 'core-js/es/weak-map';
  151. // import 'core-js/es/set';
  152. // import 'babel-polyfill';
  153. // /** IE10 and IE11 requires the following for NgClass support on SVG elements */
  154. // import 'classlist.js'; // Run `npm install --save classlist.js`.
  155. // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
  156. // import 'core-js/es/reflect';
  157. /**
  158. * Web Animations `@angular/platform-browser/animations`
  159. * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
  160. * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
  161. */
  162. /**
  163. * By default, zone.js will patch all possible macroTask and DomEvents
  164. * user can disable parts of macroTask/DomEvents patch by setting following flags
  165. * because those flags need to be set before `zone.js` being loaded, and webpack
  166. * will put import in the top of bundle, so user need to create a separate file
  167. * in this directory (for example: zone-flags.ts), and put the following flags
  168. * into that file, and then add the following code before importing zone.js.
  169. * import './zone-flags.ts';
  170. *
  171. * The flags allowed in zone-flags.ts are listed here.
  172. *
  173. * The following flags will work for all browsers.
  174. *
  175. * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
  176. * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
  177. * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
  178. *
  179. * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
  180. * with the following flag, it will bypass `zone.js` patch for IE/Edge
  181. *
  182. * (window as any).__Zone_enable_cross_context_check = true;
  183. *
  184. */
  185. /***************************************************************************************************
  186. * Zone JS is required by default for Angular itself.
  187. */
  188. // import 'zone.js';
  189. // import 'zone.js/dist/long-stack-trace-zone.js';
  190. /***************************************************************************************************
  191. * APPLICATION IMPORTS
  192. */
  193. import "zone.js/dist/zone"; // Included with Angular CLI.
  194. // import 'babel-polyfill';
  195. // zone.js需在babel-polyfill之前引入