fix(jQuery): cooperate with other libraries monkey-patching jQuery.cleanData

Some libraries (like jQuery UI) patch jQuery.cleanData as well. This commit
makes Angular work correctly even if such external patching was done after
the Angular one.

Fixes #8471

/cc @IgorMinar
Right. There's a larger question of how we want to proceed in various
script configurations. Currently if jQuery is included after Angular,
Angular will just not use it but otherwise it should work.

This PR is aimed at addressing the problem that when anything
monkey-patches jQuery.cleanData after Angular, the code stops working.
jQuery UI is given as an example (this one was actually reported) so one
can think why don't we just disallow it but: 1) it's hard to impossible to
provide a meaningful error message then; 2) it's about other libs as well.

So I think this change is needed but we're fine if we don't use jQuery if
it's loaded after Angular.

If we do want to bring back the support then it's going to be harder to
make it resilient. We could, though, set a flag on the jQuery object saying
if it was patched by us or not. We could then invoke this function as many
times we want and it would patch if and only if the particular jQuery
instance hasn't been patched by us yet.

Your call. :)


On Tue, Aug 12, 2014 at 6:24 PM, Igor Minar <notifications@github.com>
wrote:

> In src/Angular.js:
>
> >  function bindJQuery() {
> > -  var originalCleanData;
> > +  if (bindJQueryFired) {
> > +    return;
>
> this is weird. somehow, sometime in the past we broke this. and I can't
> even see in git logs when or how it happened.
>
> the way this used to work is that we would try to bind when angular.js is
> loaded and then again on bootstrap. That way we get to use jQuery even if
> it was loaded after angular. Obviously things don't work like this any
> more. It's kind of surprising that nobody has complained about this.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/angular/angular.js/pull/8486/files#r16124157>.
>



-- 
Michał Gołębiowski