-
Notifications
You must be signed in to change notification settings - Fork 484
support "jQuery" #512
Comments
I am assuming you mean only for pre-rendering, right? This wouldn't make sense for re-rendering. |
pre-render to re-render |
foo man choo |
Seriously, though, if you are ONLY pre-rendering then we can use your headless browser technique to allow for jQuery and other browser specific stuff, but it won't work with re-rendering. |
Why is this an issue? Angular2 has the capabilities of jQuery already, doesn't it? And from what I understand, jQuery is a fancy wrapper for I just can't see why you feel the need to support jquery |
In an ideal world we don't need it at all, but there's still some developers who use it (or plugins/libraries that use it), so unfortunately Universal could use some sort of patch available for them. It's not an easy implementation of course... Eventually I want to try and tackle at least suppressing Polymer from rendering server-side (so it doesn't error out), since some people use ng2&polymer mix as well. |
Yes, Mark is right. It comes down to the fact that the server doesn't have the full DOM. So, libraries that directly touch the DOM either have to be ignored (i.e. stubbed out to do nothing) or patched in some way. So, for example when you call I think the direction we are going to try and go is to limit patching within the core universal lib as much as possible to avoid bloat. You can always patch that locally if you want BUT the much better solution IMO is to isolate all code that directly touches the DOM into client-only components and services (ideally a service). If you think about it...almost all use cases for jQuery will be client-only anyways. You don't need that functionality on the server. So just put it in a client-only service and there is no need to patch. I think the reason why Patrick is exploring this in spite of what I am saying is that people often have legacy code that is hard to refactor so it is nice to have some level of support AND with pre-rendering (which is done at the command line before you deploy static assets) you could theoretically have a little more jQuery support. Let me know if that makes sense or if you have other questions. |
That is exactly what I've been doing, if (isBrowser) {
import "jquery";
} for those who really need it /s Thing is, I've had to work around server rendering errors such as "Backwards compatibility" makes sense of course, but it's just that there's still issues within the angular 2 framework, I don't have any further questions but thanks for the answers. |
So, totally fine to do |
Zone.js allows us to support anything now |
Woah what, how's that? @gdi2290 🎱 |
it's a ton of magic but it makes the impossible possible ;) |
I updated this issue to only focus on jQuery while browser globals are moved to this issue #534 |
Is there any example out there which will explain how to use |
won't be supported officially |
? but what is the best way to refactor so that server ignores jquery ($) ? is it Im looking for a solution that will make the server ignore jquery instead of refactoring component code. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
make Universal easy enough to support any browser tech
update: I have a new Context design that will allow us to support this
The text was updated successfully, but these errors were encountered: