Use of "window" on disqus.component breaks angular universal
Closed this issue · 12 comments
This line "if (this.window.DISQUS === undefined) {" on disqus.component.js causes angular universal to break, it would be nice if you guys could change it so it plays nice with universal.
window, document, navigator, and other browser types - do not exist on the server - so using them, or any library that uses them (jQuery for example) will not work. You do have some options, if you truly need some of this functionality:
If you need to use them, consider limiting them to only your main.client and wrapping them situationally with the imported isBrowser / isNode features from Universal. import { isBrowser, isNode } from 'angular2-universal';
Hi @ferares, which the version are you using 1.0.3 or 1.0.4 ?
1.0.3 @MurhafSousli
You seem to have a window.service, but i'm not sure you're using it
@ferares ofcourse I'm using it, but window
is not supported in Universal, and I haven't test it the module there. but I will try a trick in the next update and you tell me if it works
@ferares try 1.0.6 and let me know
now the issue is on line 38 "script.setAttribute('data-timestamp', new Date().getTime().toString());" of disqus.component.js
"TypeError: script.setAttribute is not a function"
I think changing the line to "this.renderer.setElementAttribute(script, 'data-timestamp', new Date().getTime().toString());" fixes it
@ferares I'm closing this one as fixed. the new issue should be in a separated thread.
As I mentioned I haven't worked with universal yet, so it's difficult for me to tell, but I suggest you try to find the correct fix within your project, then fork this repo update it with your fix and then open a pull request and I will review and merge it 😉
Did you fix this angular universal issue ? Its still breaking the server side rendering
@ranavc32 I mistakenly removed universal support, It is fixed now in 2.1.1
Okay , Thanks for the update @MurhafSousli . I will try this version and let you know how it goes.
Its working nice, still while building solution its showing a warning saying it will cause problem in
angular 5.X.
Thanks Man :)