-
Notifications
You must be signed in to change notification settings - Fork 27.4k
enables AngularJS to use any jQuery, implementing issue #608 #2163
enables AngularJS to use any jQuery, implementing issue #608 #2163
Conversation
Could you describe the reasoning why you need this feature? Also we would need unit tests. |
Hi, The reason for this feature is if you have an app in which you use an older version of jQuery (say 1.4.4) and Angular automatically loads it, even if methods like In this way, we can explicitly tell Angular which jQuery to use, but if not specified, its behavior will not be changed. Due to the fact Thanks, |
Just a drive-by comment if you are still working on this PR:
|
@vmihai - are you still interested in moving this forward? |
@petebacondarwin - I am interested, however I did not have time to set-up testing as suggested by jbdeboer. |
@vmihai - are you likely to have time in the next few weeks? If not, I suggest we close this PR for now and when you have time you can reopen it or recreate a new one... |
This is quite important in a scenario where AngularJS ir just a part in a legacy app, that uses old jQuery version (can't update), which does not work well with AngularJS. |
…ting issue #608 - grunt test:forcejqlite
I've also added an unit test. Besides To test this, run I have also submitted the CLA form as an individual. Thanks, |
Any feedback/decision on this pull request (code or tests)? Thanks, |
I don't really like the global flag approach. I wonder if we could add a third parameter to angular.bootstrap?
You then pass in either your own version of jQuery to use:
@vmihai - what do you think? |
Hi Pete, Yes, the Also, if we do this, apps that use the default jQuery ( Let me know what you think about this. |
Global variable is not a cool solution, but it's not that bad. And maybe for greater flexibility, we should use a single global object with all (future) relevant flags? Like:
|
Yes, this sounds better and also adds support for future. @mhevery, @petebacondarwin What do you think about this? If it's OK, I can implement it like this. Thanks, |
|
The global variable approach causes too many issues. I like the bootstrap option suggestion. For greater flexibility the api should be:
the options map would for now contain only a single recognized property: so you would use it as:
|
@IgorMinar - I think the default should be |
@petebacondarwin but that's a breaking change. is that intentional? |
What I meant was that Pete
|
+1 |
Closing due to inactivity. Please reopen once the issues brought up by Igor are resolved. |
oy, just ran into this today.I have a legacy app that is stuck on jquery 1.6. I have started to move parts over to angular and am blocked from using 1.2 rc due to jquery dependency. It would be very nice to be able to just config the angular part to use jqlite. I can see this in many scenarios w/ developers mixing in angular functionality into apps that have older jquery for various reasons. Depending on a globally loaded library implicitly doesn't seem very angular-ish. Providing a config mechanism does. So, seems where this was left was "what should the default be?". I would suggest making options an optional hash and it not provided or no 'jquery' value specified, just revert to the current behavior. So, no apps would break. // existing behavior // Then all of the variations that @IgorMinar mentioned above. |
@petebacondarwin I'm looking at the code this morning, trying to see how this might work. You had mentioned "there is no reason why bindJQuery needs to be run before bootstrap, other than to search for an ng-app attribute, so we ought to be able to rework this." I would love your thoughts on what this looks like; not calling bindJQuery always on load. @IgorMinar re: not driving this with a global - seems we already have a global dependency with NG_DEFER_BOOTSTRAP. So, a pragmatic approach might be to drive this off of NG_USEJQLITE in window.name. Do 2 wrongs make a right? :) More thoughts on this... I don't think it needs to be as complicated as provide which version of jquery we want angular to use. I believe jquery recommends only one version per page, so the angular config would seem best to be just an override to ignore window.jquery and use jqlite; ala NG_USEJGLITE |
+1 for @marknadig thoughts |
1 similar comment
+1 for @marknadig thoughts |
02dc2aa
to
fd2d6c0
Compare
cad9560
to
f294244
Compare
e8dc429
to
e83fab9
Compare
4dd5a20
to
998c61c
Compare
Unfortunately this solution ( This monkey patching causes conflicts with other libraries that patch jQuery, such as jQueryUI. AngularJS should not modify global objects (like jQuery), however, even if it does, it should be an explicit option to just use the internal jqLite, even if the external one supports |
Could you provide an example? I've fixed some of those issues in Angular 1.3 and using it together with jQuery UI should work now. |
What's taking so long with this? We have a breaking change because our version of jQuery is old (which we can't update throughout the system) and new development using 1.3 is bootstrapping too early, before our modules are loaded. This is not the case if jQuery is removed. |
Mainly the relevant lack of my free time in November. I'm commited to make it happen in Angular 1.3, I just cannot promise I'll be able to finish it up before December. The planned solution is to have an
We'll also add a separate option to |
Anything I can do to help? Sounds like an easy fix and could donate my time On Fri, Nov 21, 2014, 11:57 PM Michał Gołębiowski notifications@github.com
|
If you want, you may look at how ng-csp is implemented, the mechanism for If you submit a PR, please cc me on it, I'll make sure it's reviewed & Michał Gołębiowski |
Great! Thanks On Sat, Nov 22, 2014, 1:19 PM Michał Gołębiowski notifications@github.com
|
Alright, I started this and got a directive going, but I'm not sure where should I set the variable. The $sniffer service doesn't seem appropriate. Plus, I'm curious as to how it's going to work with the angular.bootstrap function. Do we need a 3rd parameter on the function for 'config', which could take in an object with keys like ngCsp and ngJq? Should this config be a private service itself? |
@mzgol Can you please provide some direction? Thanks. |
I'll look into it tomorrow. Michał Gołębiowski |
@mboudreau Sorry for the delay. After looking at what we have currently I think being able to pass an additional parameter to Line 1288 in 7fd2dc1
This is fine since strict-di can be enabled for one Angular app and disabled for another.
Meanwhile, in the Lines 872 to 873 in 7fd2dc1
Since As for where to put it, angular.js/src/ng/directive/ngCsp.js Lines 172 to 174 in 7fd2dc1
Since we need the value of Line 891 in 7fd2dc1
The logic for finding the Lines 1449 to 1498 in 7fd2dc1
Let me know if you have further questions. |
Perfect. I'll get right on that. On Wed, Dec 10, 2014, 12:06 PM Michał Gołębiowski notifications@github.com
|
Thanks for working on this. I am very interested in this feature and I would be glad to help. Ping me if I can do anything. @mboudreau where can I follow your progress on this? |
I should have something done in the next 24 hours. Will include the pull On Wed, Dec 10, 2014, 6:39 PM Antoine Pairet notifications@github.com
|
Alright, I've created the first draft and tested it thoroughly using unit tests on the jq() function and manual testing for the ng-jq attribute. It works quite well. The only issue is that I'm not sure how to test the ng-jq attribute. I should probably use e2e testing I believe, but need some direction as to where to put it. Tried to find the e2e tests for csp without any luck since they're very similar. Any further help would be appreciated. |
Closing in favour of #10761 |
Enables AngularJS to use any jQuery library by using the
window.angularjsUseJquery
variable, that can have the following values:undefined
/null
/false
- the default behavior (try to use window.jQuery, if not, use internal)"internal"
- use the internal jQuery lite, no matter which other jQuery is present in the pageAlso updated the documentation (manual bootstrapping guide) to include details about this feature.