chartjs / chartjs/Chart.js

requestAnimationFrame() polyfill does get applied for dedicated workers for no reason

Open
#11,891 0 comments 1 reaction 0 assignees View on GitHub
type: bug
Dominant language
JavaScript
Stars
67.7k
Forks
11.9k
Avg merge
7h 39m
Merged PRs (30d)
5

Description

### Expected behavior

a dedicated worker has full support for `requestAnimationFrame()`
https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope/requestAnimationFrame

```
/**
* Request animation polyfill
*/
export const requestAnimFrame = (function() {
if (typeof window === 'undefined') {
return function(callback) {
return callback();
};
}
return window.requestAnimationFrame;
}());
```

so this will get applied, which is not good.

what you want to check instead:
```
if (!globalThis.requestAnimationFrame) {
// smart polyfill
}
```

### Current behavior

polyfill getting applied in dedicated workers

### Reproducible sample

https://github.com/neomjs/chartjs-demo

### Optional extra steps/info to reproduce

_No response_

### Possible solution

_No response_

### Context

_No response_

### chart.js version

v4.4.4

### Browser name and version

_No response_

### Link to your project

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.