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

window is not defined issue #707

Closed
niangoss opened this issue Mar 9, 2018 · 4 comments
Closed

window is not defined issue #707

niangoss opened this issue Mar 9, 2018 · 4 comments
Labels

Comments

@niangoss
Copy link

niangoss commented Mar 9, 2018

IMPORTANT: please note that the autoFormat feature (format-as-you-type) was removed in v8.0.0 - read more here: #346. Please do not open any new issues about this topic.

IMPORTANT: we use libphonenumber for formatting and validation - if your issue relates to one of these things, please check their test site first and if you see the problem there please file an issue with them instead: https://rawgit.com/googlei18n/libphonenumber/master/javascript/i18n/phonenumbers/demo-compiled.html

Steps to reproduce

When you use it in angular 5 universal server side rendering project.
window exist only on browser side, we got "window is not defined" issue when factory($, window, document) is called (build/js/intlTelInput.js file at line 11)

Expected behaviour

check if 'window' exists before use it

Actual behaviour

window is not defined Exception is thrown when window does not exist

Initialisation options

List any options you're using e.g. utilsScript or preferredCountries

@jackocnr
Copy link
Owner

jackocnr commented Mar 9, 2018

Hmm interesting! I would be open to a pull request to check if window exists before attempting to use it, and if not, then it immediately sets windowLoaded to true. I just checked and we reference window quite a few times in the code, but I suppose only the initialisation path is relevant for server side rendering.

@yacineblr
Copy link

Do you have any news?

@jackocnr
Copy link
Owner

No update yet I'm afraid. But a quick search revealed this thread on the angular universal repo: angular/universal#830 which suggests that when you have a problem with a module trying to access window - that you either (A) only import that module in main.ts (which I'm guessing means it wont be run on the server side?), or (B) define global['window'] on your backend. So I'm not convinced we actually need to do anything about this in the intl-tel-input plugin code. What are your thoughts?

I have never used Angular, or Angular Universal, but I'm interested to know: do you actually want to run this plugin code on the server side? And if so, why?

@jackocnr
Copy link
Owner

jackocnr commented Aug 3, 2018

Closing due to inactivity

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

No branches or pull requests

3 participants