oldie-polyfills.src.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /**
  2. * @license Highcharts JS v8.2.0 (2020-08-20)
  3. *
  4. * Old IE (v6, v7, v8) array polyfills for Highcharts v7+.
  5. *
  6. * (c) 2010-2019 Highsoft AS
  7. * Author: Torstein Honsi
  8. *
  9. * License: www.highcharts.com/license
  10. */
  11. 'use strict';
  12. (function (factory) {
  13. if (typeof module === 'object' && module.exports) {
  14. factory['default'] = factory;
  15. module.exports = factory;
  16. } else if (typeof define === 'function' && define.amd) {
  17. define('highcharts/modules/oldie-polyfills', ['highcharts'], function (Highcharts) {
  18. factory(Highcharts);
  19. factory.Highcharts = Highcharts;
  20. return factory;
  21. });
  22. } else {
  23. factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
  24. }
  25. }(function (Highcharts) {
  26. var _modules = Highcharts ? Highcharts._modules : {};
  27. function _registerModule(obj, path, args, fn) {
  28. if (!obj.hasOwnProperty(path)) {
  29. obj[path] = fn.apply(null, args);
  30. }
  31. }
  32. _registerModule(_modules, 'Extensions/OldiePolyfills.js', [], function () {
  33. /* *
  34. *
  35. * (c) 2010-2020 Torstein Honsi
  36. *
  37. * License: www.highcharts.com/license
  38. *
  39. * Simple polyfills for array functions in old IE browsers (6, 7 and 8) in
  40. * Highcharts v7+. These polyfills are sufficient for Highcharts to work, but
  41. * for fully compatible polyfills, see MDN.
  42. *
  43. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  44. *
  45. * */
  46. /* global document */
  47. /* eslint-disable no-extend-native */
  48. if (!String.prototype.trim) {
  49. String.prototype.trim = function () {
  50. return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
  51. };
  52. }
  53. if (!Array.prototype.forEach) {
  54. Array.prototype.forEach = function (fn, thisArg) {
  55. var i = 0,
  56. len = this.length;
  57. for (; i < len; i++) {
  58. if (typeof this[i] !== 'undefined' && // added check
  59. fn.call(thisArg, this[i], i, this) === false) {
  60. return i;
  61. }
  62. }
  63. };
  64. }
  65. if (!Array.prototype.map) {
  66. Array.prototype.map = function (fn
  67. // @todo support optional ctx
  68. ) {
  69. var results = [],
  70. i = 0,
  71. len = this.length;
  72. for (; i < len; i++) {
  73. results[i] = fn.call(this[i], this[i], i, this);
  74. }
  75. return results;
  76. };
  77. }
  78. if (!Array.prototype.indexOf) {
  79. Array.prototype.indexOf = function (member, fromIndex) {
  80. var arr = this, // #8874
  81. len,
  82. i = fromIndex || 0; // #8346
  83. if (arr) {
  84. len = arr.length;
  85. for (; i < len; i++) {
  86. if (arr[i] === member) {
  87. return i;
  88. }
  89. }
  90. }
  91. return -1;
  92. };
  93. }
  94. if (!Array.prototype.filter) {
  95. Array.prototype.filter = function (fn
  96. // @todo support optional ctx
  97. ) {
  98. var ret = [],
  99. i = 0,
  100. length = this.length;
  101. for (; i < length; i++) {
  102. if (fn(this[i], i)) {
  103. ret.push(this[i]);
  104. }
  105. }
  106. return ret;
  107. };
  108. }
  109. if (!Array.prototype.some) {
  110. Array.prototype.some = function (fn, thisArg) {
  111. var i = 0,
  112. len = this.length;
  113. for (; i < len; i++) {
  114. if (fn.call(thisArg, this[i], i, this) === true) {
  115. return true;
  116. }
  117. }
  118. return false;
  119. };
  120. }
  121. if (!Array.prototype.reduce) {
  122. Array.prototype.reduce = function (func, initialValue) {
  123. var context = this,
  124. i = arguments.length > 1 ? 0 : 1,
  125. accumulator = arguments.length > 1 ? initialValue : this[0],
  126. len = this.length;
  127. for (; i < len; ++i) {
  128. accumulator = func.call(context, accumulator, this[i], i, this);
  129. }
  130. return accumulator;
  131. };
  132. }
  133. if (!Function.prototype.bind) {
  134. Function.prototype.bind = function () {
  135. var thatFunc = this;
  136. var thatArg = arguments[0];
  137. var args = Array.prototype.slice.call(arguments, 1);
  138. if (typeof thatFunc !== 'function') {
  139. // closest thing possible to the ECMAScript 5
  140. // internal IsCallable function
  141. throw new TypeError('Function.prototype.bind - ' +
  142. 'what is trying to be bound is not callable');
  143. }
  144. return function () {
  145. var funcArgs = args.concat(Array.prototype.slice.call(arguments));
  146. return thatFunc.apply(thatArg, funcArgs);
  147. };
  148. };
  149. }
  150. if (!Object.keys) {
  151. Object.keys = function (obj) {
  152. var result = [],
  153. prop;
  154. for (prop in obj) {
  155. if (Object.hasOwnProperty.call(obj, prop)) {
  156. result.push(prop);
  157. }
  158. }
  159. return result;
  160. };
  161. }
  162. // Add a getElementsByClassName function if the browser doesn't have one
  163. // Limitation: only works with one class name
  164. // Copyright: Eike Send https://eike.se/nd
  165. // License: MIT License
  166. if (!document.getElementsByClassName) {
  167. document.getElementsByClassName = function (search) {
  168. var d = document,
  169. elements,
  170. pattern,
  171. i,
  172. results = [];
  173. if (d.querySelectorAll) { // IE8
  174. return d.querySelectorAll('.' + search);
  175. }
  176. if (d.evaluate) { // IE6, IE7
  177. pattern = './/*[contains(concat(\' \', @class, \' \'), \' ' +
  178. search + ' \')]';
  179. elements = d.evaluate(pattern, d, null, 0, null);
  180. while ((i = elements.iterateNext())) {
  181. results.push(i);
  182. }
  183. }
  184. else {
  185. elements = d.getElementsByTagName('*');
  186. pattern = new RegExp('(^|\\s)' + search + '(\\s|$)');
  187. for (i = 0; i < elements.length; i++) {
  188. if (pattern.test(elements[i].className)) {
  189. results.push(elements[i]);
  190. }
  191. }
  192. }
  193. return results;
  194. };
  195. }
  196. });
  197. _registerModule(_modules, 'masters/modules/oldie-polyfills.src.js', [], function () {
  198. });
  199. }));