Skip to content
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

Fails when displaying page in actual Electron window #5

Open
rahatarmanahmed opened this issue Oct 6, 2016 · 2 comments
Open

Fails when displaying page in actual Electron window #5

rahatarmanahmed opened this issue Oct 6, 2016 · 2 comments

Comments

@rahatarmanahmed
Copy link

rahatarmanahmed commented Oct 6, 2016

Yoooooo, I spent like 3 hours digging through browserified & minified fivethirtyeight production code trying to figure out why the 2016 forecast page didn't render graphs when I embedded it in an Electron app. (Trying to make a wall display of the election forecast using y'alls visualizations).

Eventually I figured out it was because of this line: https://github.com/fivethirtyeight/d3-pre/blob/master/src/index.js#L17 which recognizes electron even if I disable nodeIntegration or isolate the page in a webview tag

Easy fix for me, I can just change the userAgent. But I thought I'd let you know for the miniscule chance that it might be useful for you. I would suggest using something like is-electron-renderer. Feel free to close this issue if you don't care, though.

@mathisonian
Copy link
Contributor

Hmm that is an interesting use case, thanks for pointing it out. Maybe I'm wrong but wouldn't you would still be facing a similar problem if we used that other module?

Maybe its better to set some kind of explicit flag in d3-pre-renderer and check for that here.

@rahatarmanahmed
Copy link
Author

Oh yeah is-electron-renderer wouldn't exactly work, my bad. But you can see how they detect a node-like environment by checking for the existence of process. You just need to check for that instead of the userAgent (which will always say Electron even if you disable node integration).

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

No branches or pull requests

2 participants