-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Fix viewer's "Export -> Save as..." with Firefox. #1626
Conversation
Only thing I wonder is if we should call |
I added a new patch which also removes the node from DOM and changes the |
@@ -361,9 +361,12 @@ class LighthouseViewerReport extends LighthouseReport { | |||
const a = document.createElement('a'); | |||
a.download = `${filename}${ext}`; | |||
a.href = URL.createObjectURL(blob); | |||
document.body.appendChild(a); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
document.body.appendChild(a); // Firefox requires anchor be in the DOM.
setTimeout(_ => URL.revokeObjectURL(a.href), 500); // cleanup. | ||
// cleanup. | ||
document.body.removeChild(a); | ||
setTimeout(_ => URL.revokeObjectURL(a.href), 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to keep the 500ms delay just to be on the safe side.
@ebidel: done. I kept the interval to 500, even though it seems unneeded from my tests. |
For some weird reason, Firefox needs `document.body.appendChild(a)` too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. Thanks again.
For some weird reason, Firefox needs
document.body.appendChild(a)
too.Fixes #1574.