web.timers.js 754 B

1234567891011121314151617181920
  1. // ie9- setTimeout & setInterval additional parameters fix
  2. var global = require('./_global');
  3. var $export = require('./_export');
  4. var userAgent = require('./_user-agent');
  5. var slice = [].slice;
  6. var MSIE = /MSIE .\./.test(userAgent); // <- dirty ie9- check
  7. var wrap = function (set) {
  8. return function (fn, time /* , ...args */) {
  9. var boundArgs = arguments.length > 2;
  10. var args = boundArgs ? slice.call(arguments, 2) : false;
  11. return set(boundArgs ? function () {
  12. // eslint-disable-next-line no-new-func
  13. (typeof fn == 'function' ? fn : Function(fn)).apply(this, args);
  14. } : fn, time);
  15. };
  16. };
  17. $export($export.G + $export.B + $export.F * MSIE, {
  18. setTimeout: wrap(global.setTimeout),
  19. setInterval: wrap(global.setInterval)
  20. });