Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

$animateProvider.classNameFilter silently fails #14806

Closed
thany opened this issue Jun 20, 2016 · 1 comment
Closed

$animateProvider.classNameFilter silently fails #14806

thany opened this issue Jun 20, 2016 · 1 comment

Comments

@thany
Copy link

thany commented Jun 20, 2016

Note: for support questions, please use one of these channels: https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#question. This repository's issues are reserved for feature requests and bug reports.

Do you want to request a feature or report a bug?
Bug.

What is the current behavior?
$animateProvider.classNameFilter silently fails by throwing an exception and eating it. This effectively stops the whole application from working without any messages or error in the console, or anywhere else. This results in the infamous "white screen of death".

The error that is thrown (and eaten) is an Angular exception that manages to point to a nonexisting url:

Error: [$animate:nongcls] http://errors.angularjs.org/1.5.7/$animate/nongcls?p0=ng-animate

I have no way of knowing what this "nongcls" error might mean.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (template: http://plnkr.co/edit/tpl:yBpEi4).
In any app, include ngAnimate module and add a config to the module:

.config(function ($animateProvider) {
   $animateProvider.classNameFilter(/ng-animate/);
})

What is the expected behavior?
It should just do as described in the API documentation. And if anything, certainly should not eat its exceptions. That's horrible for development!

What is the motivation / use case for changing the behavior?
It's eating exceptions. And it doesn't work as described.

Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.
Angular 1.5.7 release, Windows 10, Firefox 47.
This project is an upgrade from Angular 1.3.16, and back then, this worked fine, even in the same browser.

Other information (e.g. stacktraces, related issues, suggestions how to fix)
There seems to be an undocumented check against some magic value in angular.js (yep, it's not even in angular-animate.js, it's in the core for some reason):

this.classNameFilter = function(expression) {
    if (arguments.length === 1) {
      this.$$classNameFilter = (expression instanceof RegExp) ? expression : null;
      if (this.$$classNameFilter) {
        var reservedRegex = new RegExp("(\\s+|\\/)" + NG_ANIMATE_CLASSNAME + "(\\s+|\\/)");
        if (reservedRegex.test(this.$$classNameFilter.toString())) {
          throw $animateMinErr('nongcls','$animateProvider.classNameFilter(regex) prohibits accepting a regex value which matches/contains the "{0}" CSS class.', NG_ANIMATE_CLASSNAME);

        }
      }
    }
    return this.$$classNameFilter;
  };

Like I said, this is undocumented, so perhaps this is a bug in the documentation, perhaps in the code. The worst thing, I cannot stress enough, is that this exception is not thrown, but eaten.

@Narretz
Copy link
Contributor

Narretz commented Jun 21, 2016

I get a very nice exception in http://plnkr.co/edit/WYIkjYnZU1l1Ng3JPDEc?p=preview

The error has no documentation though, I agree that needs to be fixed.

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

No branches or pull requests

3 participants