Skip to content

fix: invalid invocation on raf #1051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2021
Merged

Conversation

huozhi
Copy link
Member

@huozhi huozhi commented Mar 19, 2021

Fixes #1046 #1050

Minimal repro

a = {
   raf: window.requestAnimationFrame,
   raf_pure: f => window.requestAnimationFrame(f)
}

f = () => console.log(1)
a.raf(f) // Error
// Chrome: Uncaught TypeError: Illegal invocation
// Firefox: Uncaught TypeError: 'requestAnimationFrame' called on an object that does not implement interface Window.

a.raf_pure(f) // log `1` in console

Possible root cause:

checked the repro in #1050, the line calling rAF is compiled to c.rAF(n), rAF called on an object c, which represents a module. We need to make it pure.

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 70d9a61:

Sandbox Source
SWR-Basic Configuration
SWR-States Configuration
SWR-Infinite Configuration

Copy link
Member

@shuding shuding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find

@shuding shuding merged commit 58196c5 into vercel:master Mar 19, 2021
@koba04
Copy link
Collaborator

koba04 commented Mar 19, 2021

That's so great! Thank you for your fix!

@huozhi huozhi deleted the fix-invalid-invocation branch March 19, 2021 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing requestAnimationFrame after upgrading to 0.5.3
3 participants