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

Wrong value of this passed to module #248

Closed
getdave opened this issue May 29, 2015 · 4 comments
Closed

Wrong value of this passed to module #248

getdave opened this issue May 29, 2015 · 4 comments

Comments

@getdave
Copy link

getdave commented May 29, 2015

I'm using webfontloader via WebPack CommonJS module. Webpack compiles fine but when I load up the JS on the page I get an error

Uncaught TypeError: Cannot read property 'userAgent' of undefined

So userAgent lives on window.navigator so I checked to see what window referred to inside the webfontloader.js file in the node_modules directory and I see it's set to this which is passed in via the module closure.

If I alter the this to window and recompile it works fine.

I'm not sure if this is a webfontloader issue or a misconfig of WebPack. However I've noticed a similar issue #246 which indicates there may have been a similar issue before?

Please can you advise? Web Font Loader v1.6.0

Update: may relate to webpack/webpack#97

@bramstein
Copy link
Contributor

Could you try v1.6.2 to see if this is fixed?

@getdave
Copy link
Author

getdave commented May 29, 2015

Unfortunately the same error persists. Logging this return a plain JavaScript object {}

@bramstein
Copy link
Contributor

Hmm, there is only one place in the code that reads userAgent and it correctly references window.navigator.userAgent. It looks like webpack isn't setting up the window correctly in this case.

@getdave
Copy link
Author

getdave commented May 29, 2015

I believe it is a webpack issue. Closing.

@getdave getdave closed this as completed May 29, 2015
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