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

Fix debug calls while in a preload script inside Electron #377

Closed
wants to merge 2 commits into from

Conversation

MarshallOfSound
Copy link

In electron preload scripts document.documentElement is null, this is quite a simple fix that simply checks for a good value 👍

In `electron` preload scripts `document.documentElement` is null
@MarshallOfSound MarshallOfSound changed the title Update browser.js Fix debug calls while in a preload script inside Electron Dec 17, 2016
return (typeof document !== 'undefined' && 'WebkitAppearance' in document.documentElement.style) ||
// document.documentElement is null in Electron preload scripts
return (typeof document !== 'undefined' && document.documentElement
'WebkitAppearance' in document.documentElement.style) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

wondering if you meant to add an && to the end of the null pointer check document.documentElement? This looks like a syntax error

Copy link
Author

Choose a reason for hiding this comment

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

Idek where that && went, let's pretend this didn't happen and move on 😆

@thebigredgeek
Copy link
Contributor

Pretty sure there is a syntax error here. I added linting to browser.js on master, but I don't think it ran on this PR.

@anaisbetts
Copy link
Contributor

This is a dupe of #368, no?

@MarshallOfSound
Copy link
Author

@paulcbetts Hmmm, maybe I got a module before that patch or someone hasn't updated their entire dependency tree. I'll wipe node-modules try again 👍

@graysonlang
Copy link

Just a heads up: If you want this to not error out in the context of Electron's main process (which it did in earlier versions), you will also need to check for typeof navigator !== 'undefined' on lines 56 and 58.

@thebigredgeek
Copy link
Contributor

@MarshallOfSound conflicts :(

@anaisbetts
Copy link
Contributor

Just a heads up: If you want this to not error out in the context of Electron's main process (which it did in earlier versions), you will also need to check for typeof navigator !== 'undefined' on lines 56 and 58.

In the main process we shouldn't ever get to browser.js because we will have been redirected to use the node version, peep #324

@MarshallOfSound
Copy link
Author

Resetting yarn cache finally pulled in a good version of this module 👍 @paulcbetts fix works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants