Welcome to mirror list, hosted at ThFree Co, Russian Federation.

polyfills.js « commons « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 655109bad9a91d716ec401b15cd47a16f6fdfb45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
 * Polyfill
 * @what requestIdleCallback
 * @why To align browser features
 * @browsers Safari (all versions)
 * @see https://caniuse.com/#feat=requestidlecallback
 */
window.requestIdleCallback =
  window.requestIdleCallback ||
  function requestShim(cb) {
    const start = Date.now();
    return setTimeout(() => {
      cb({
        didTimeout: false,
        timeRemaining: () => Math.max(0, 50 - (Date.now() - start)),
      });
    }, 1);
  };

window.cancelIdleCallback =
  window.cancelIdleCallback ||
  function cancelShim(id) {
    clearTimeout(id);
  };