oldie-polyfills.src.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /**
  2. * @license Highcharts JS v9.1.1 (2021-06-04)
  3. *
  4. * Old IE (v6, v7, v8) array polyfills for Highcharts v7+.
  5. *
  6. * (c) 2010-2021 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-2021 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. // Adapted from https://johnresig.com/blog/objectgetprototypeof/
  151. if (!Object.getPrototypeOf) {
  152. if (typeof 'test'.__proto__ === 'object') { // eslint-disable-line no-proto
  153. Object.getPrototypeOf = function (object) {
  154. return object.__proto__; // eslint-disable-line no-proto
  155. };
  156. }
  157. else {
  158. Object.getPrototypeOf = function (object) {
  159. var proto = object.constructor.prototype;
  160. if (proto === object) {
  161. return {}.constructor.prototype;
  162. }
  163. // May break if the constructor has been tampered with
  164. return proto;
  165. };
  166. }
  167. }
  168. if (!Object.keys) {
  169. Object.keys = function (obj) {
  170. var result = [],
  171. prop;
  172. for (prop in obj) {
  173. if (Object.hasOwnProperty.call(obj, prop)) {
  174. result.push(prop);
  175. }
  176. }
  177. return result;
  178. };
  179. }
  180. // Add a getElementsByClassName function if the browser doesn't have one
  181. // Limitation: only works with one class name
  182. // Copyright: Eike Send https://eike.se/nd
  183. // License: MIT License
  184. if (!document.getElementsByClassName) {
  185. document.getElementsByClassName = function (search) {
  186. var d = document,
  187. elements,
  188. pattern,
  189. i,
  190. results = [];
  191. if (d.querySelectorAll) { // IE8
  192. return d.querySelectorAll('.' + search);
  193. }
  194. if (d.evaluate) { // IE6, IE7
  195. pattern = './/*[contains(concat(\' \', @class, \' \'), \' ' +
  196. search + ' \')]';
  197. elements = d.evaluate(pattern, d, null, 0, null);
  198. while ((i = elements.iterateNext())) {
  199. results.push(i);
  200. }
  201. }
  202. else {
  203. elements = d.getElementsByTagName('*');
  204. pattern = new RegExp('(^|\\s)' + search + '(\\s|$)');
  205. for (i = 0; i < elements.length; i++) {
  206. if (pattern.test(elements[i].className)) {
  207. results.push(elements[i]);
  208. }
  209. }
  210. }
  211. return results;
  212. };
  213. }
  214. });
  215. _registerModule(_modules, 'masters/modules/oldie-polyfills.src.js', [], function () {
  216. });
  217. }));