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

Commit 899c52e

Browse files
committed
fixup! fix($animate): improve detection on ng-animate in classNameFilter RegExp
1 parent 5bf4ab0 commit 899c52e

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@ngdoc error
2+
@name $animate:nongcls
3+
@fullName `ng-animate` class not allowed
4+
@description
5+
6+
This error occurs, when trying to set `$animateProvider.classNameFilter()` to a RegExp containing
7+
the reserved `ng-animate` class. Since `.ng-animate` will be added/removed by `$animate` itself,
8+
using it as part of the `classNameFilter` RegExp is not allowed.

test/ngAnimate/animateSpec.js

+15-21
Original file line numberDiff line numberDiff line change
@@ -257,28 +257,22 @@ describe('animations', function() {
257257

258258
it('should throw a minErr if a regex value is used which partially contains or fully matches the `ng-animate` CSS class',
259259
module(function($animateProvider) {
260-
var errorMessage = '$animateProvider.classNameFilter(regex) prohibits accepting a regex ' +
261-
'value which matches/contains the "ng-animate" CSS class.';
262-
263-
assertError(/ng-animate/, true);
264-
assertError(/first ng-animate last/, true);
265-
assertError(/ng-animate-special/, false);
266-
assertError(/first ng-animate-special last/, false);
267-
assertError(/first ng-animate ng-animate-special last/, true);
268-
assertError(/(ng-animate)/, true);
269-
assertError(/(foo|ng-animate|bar)/, true);
270-
assertError(/(foo|)ng-animate(|bar)/, true);
271-
272-
function assertError(regex, bool) {
273-
var expectation = expect(function() {
260+
expect(setFilter(/ng-animate/)).toThrowMinErr('$animate', 'nongcls');
261+
expect(setFilter(/first ng-animate last/)).toThrowMinErr('$animate', 'nongcls');
262+
expect(setFilter(/first ng-animate ng-animate-special last/)).toThrowMinErr('$animate', 'nongcls');
263+
expect(setFilter(/(ng-animate)/)).toThrowMinErr('$animate', 'nongcls');
264+
expect(setFilter(/(foo|ng-animate|bar)/)).toThrowMinErr('$animate', 'nongcls');
265+
expect(setFilter(/(foo|)ng-animate(|bar)/)).toThrowMinErr('$animate', 'nongcls');
266+
267+
expect(setFilter(/ng-animater/)).not.toThrow();
268+
expect(setFilter(/my-ng-animate/)).not.toThrow();
269+
expect(setFilter(/first ng-animater last/)).not.toThrow();
270+
expect(setFilter(/first my-ng-animate last/)).not.toThrow();
271+
272+
function setFilter(regex) {
273+
return function() {
274274
$animateProvider.classNameFilter(regex);
275-
});
276-
277-
if (bool) {
278-
expectation.toThrowMinErr('$animate', 'nongcls', errorMessage);
279-
} else {
280-
expectation.not.toThrow();
281-
}
275+
};
282276
}
283277
})
284278
);

0 commit comments

Comments
 (0)