Description
Do you want to request a feature or report a bug? Bug
What is the current behavior?
TypeError: "'requestAnimationFrame' called on an object that does not implement interface Window."
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
In the WebExtension content script, globalThis !== window.
So when const requestAnimationFrame = window.requestAnimationFrame
, the this
binding of rAF
is lost.
In the after calling, rAF
rebinds to the globalThis, but globalThis doesn't implements Window interface.
PoC: Install this extension in the Firefox and you will see the error reported.
try {
const raf = window.requestAnimationFrame
raf(() => console.log('Okay.'))
} catch (e) {
console.warn(e)
}
{
"name": "rAF in content script test",
"version": "0.0.1",
"manifest_version": 2,
"content_scripts": [{ "js": ["/index.js"], "matches": ["<all_urls>"] }]
}
What is the expected behavior?
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
Firefox, in WebExtension.
Related to #16605