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

fix($animate): improve detection and handling of invalid classNameFilter RegExp #14913

Closed

Conversation

gkalpak
Copy link
Member

@gkalpak gkalpak commented Jul 15, 2016

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Bug fix.

What is the current behavior? (You can also link to an open issue here)

  1. $animateProvider fails to detect several invalid classNameFilter RegExps.
  2. Even if a classNameFilter RegExp is detected as invalid, $animateProvider will still use it (despite printing an error message saying that it is prohibited).

What is the new behavior (if this is a feature change)?

  1. $animateProvider does a better job detecting invalid classNameFilter RegExps (it is still not perfect though).
  2. If a classNameFilter RegExp is detected as invalid, classNameFilter will be reset to null (to avoid using an invalid RegExp).

Does this PR introduce a breaking change?
No (unless someone was hacking around the previous implementation in order to allow invalid RegExps - which they shouldn't do anyway).

Please check if the PR fulfills these requirements

Other information:
This PR contains two separate commits - which fix two different things - so that they can be liked/disliked independently.

module(function($animateProvider) {
var errorMessage = '$animateProvider.classNameFilter(regex) prohibits accepting a regex ' +
'value which matches/contains the "ng-animate" CSS class.';

assertError(/ng-animate/, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good place for a custom matcher

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was only used in this one test, so not worth it. (I refactored the test, so now assertError is gone anyway 😃)

@gkalpak gkalpak force-pushed the fix-animate-invalid-classNameFilter branch from b2f79fe to 6606b4f Compare December 19, 2016 21:47
@gkalpak
Copy link
Member Author

gkalpak commented Dec 19, 2016

Rebased on master and addressed comments.
@Narretz, @petebacondarwin: PTAL

@gkalpak gkalpak force-pushed the fix-animate-invalid-classNameFilter branch from 6606b4f to 899c52e Compare December 21, 2016 12:35
@Narretz
Copy link
Contributor

Narretz commented Jan 20, 2017

There's a style error, otherwise LGTM

@gkalpak
Copy link
Member Author

gkalpak commented Jan 25, 2017

PTAL

@Narretz
Copy link
Contributor

Narretz commented Feb 16, 2017

LGTM
The error docs close #14806 btw

@gkalpak gkalpak closed this in b55637a Feb 17, 2017
gkalpak added a commit that referenced this pull request Feb 17, 2017
ellimist pushed a commit to ellimist/angular.js that referenced this pull request Mar 15, 2017
@gkalpak gkalpak deleted the fix-animate-invalid-classNameFilter branch April 27, 2017 11:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants