oldie-polyfills.src.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /**
  2. * @license Highcharts JS v8.0.0 (2019-12-10)
  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, 'modules/oldie-polyfills.src.js', [], function () {
  33. /* *
  34. *
  35. * (c) 2010-2019 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 (!Array.prototype.forEach) {
  49. Array.prototype.forEach = function (fn, thisArg) {
  50. var i = 0, len = this.length;
  51. for (; i < len; i++) {
  52. if (typeof this[i] !== 'undefined' && // added check
  53. fn.call(thisArg, this[i], i, this) === false) {
  54. return i;
  55. }
  56. }
  57. };
  58. }
  59. if (!Array.prototype.map) {
  60. Array.prototype.map = function (fn
  61. // @todo support optional ctx
  62. ) {
  63. var results = [], i = 0, len = this.length;
  64. for (; i < len; i++) {
  65. results[i] = fn.call(this[i], this[i], i, this);
  66. }
  67. return results;
  68. };
  69. }
  70. if (!Array.prototype.indexOf) {
  71. Array.prototype.indexOf = function (member, fromIndex) {
  72. var arr = this, // #8874
  73. len, i = fromIndex || 0; // #8346
  74. if (arr) {
  75. len = arr.length;
  76. for (; i < len; i++) {
  77. if (arr[i] === member) {
  78. return i;
  79. }
  80. }
  81. }
  82. return -1;
  83. };
  84. }
  85. if (!Array.prototype.filter) {
  86. Array.prototype.filter = function (fn
  87. // @todo support optional ctx
  88. ) {
  89. var ret = [], i = 0, length = this.length;
  90. for (; i < length; i++) {
  91. if (fn(this[i], i)) {
  92. ret.push(this[i]);
  93. }
  94. }
  95. return ret;
  96. };
  97. }
  98. if (!Array.prototype.some) {
  99. Array.prototype.some = function (fn, thisArg) {
  100. var i = 0, len = this.length;
  101. for (; i < len; i++) {
  102. if (fn.call(thisArg, this[i], i, this) === true) {
  103. return true;
  104. }
  105. }
  106. return false;
  107. };
  108. }
  109. if (!Array.prototype.reduce) {
  110. Array.prototype.reduce = function (func, initialValue) {
  111. var context = this, i = arguments.length > 1 ? 0 : 1, accumulator = arguments.length > 1 ? initialValue : this[0], len = this.length;
  112. for (; i < len; ++i) {
  113. accumulator = func.call(context, accumulator, this[i], i, this);
  114. }
  115. return accumulator;
  116. };
  117. }
  118. if (!Object.keys) {
  119. Object.keys = function (obj) {
  120. var result = [], prop;
  121. for (prop in obj) {
  122. if (Object.hasOwnProperty.call(obj, prop)) {
  123. result.push(prop);
  124. }
  125. }
  126. return result;
  127. };
  128. }
  129. // Add a getElementsByClassName function if the browser doesn't have one
  130. // Limitation: only works with one class name
  131. // Copyright: Eike Send http://eike.se/nd
  132. // License: MIT License
  133. if (!document.getElementsByClassName) {
  134. document.getElementsByClassName = function (search) {
  135. var d = document, elements, pattern, i, results = [];
  136. if (d.querySelectorAll) { // IE8
  137. return d.querySelectorAll('.' + search);
  138. }
  139. if (d.evaluate) { // IE6, IE7
  140. pattern = './/*[contains(concat(\' \', @class, \' \'), \' ' +
  141. search + ' \')]';
  142. elements = d.evaluate(pattern, d, null, 0, null);
  143. while ((i = elements.iterateNext())) {
  144. results.push(i);
  145. }
  146. }
  147. else {
  148. elements = d.getElementsByTagName('*');
  149. pattern = new RegExp('(^|\\s)' + search + '(\\s|$)');
  150. for (i = 0; i < elements.length; i++) {
  151. if (pattern.test(elements[i].className)) {
  152. results.push(elements[i]);
  153. }
  154. }
  155. }
  156. return results;
  157. };
  158. }
  159. });
  160. _registerModule(_modules, 'masters/modules/oldie-polyfills.src.js', [], function () {
  161. });
  162. }));