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

Commit 5bf4ab0

Browse files
committed
fix($animate): reset classNameFilter to null when a disallowed RegExp is used
1 parent 8cdd7bd commit 5bf4ab0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/ng/animate.js

+1
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ var $AnimateProvider = ['$provide', /** @this */ function($provide) {
252252
if (classNameFilter) {
253253
var reservedRegex = new RegExp('[(\\s|\\/)]' + NG_ANIMATE_CLASSNAME + '[(\\s|\\/)]');
254254
if (reservedRegex.test(classNameFilter.toString())) {
255+
classNameFilter = null;
255256
throw $animateMinErr('nongcls', '$animateProvider.classNameFilter(regex) prohibits accepting a regex value which matches/contains the "{0}" CSS class.', NG_ANIMATE_CLASSNAME);
256257
}
257258
}

test/ngAnimate/animateSpec.js

+13
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,19 @@ describe('animations', function() {
283283
})
284284
);
285285

286+
it('should clear the `classNameFilter` if a disallowed RegExp is passed',
287+
module(function($animateProvider) {
288+
var validRegex = /no-ng-animate/;
289+
var invalidRegex = /no ng-animate/;
290+
291+
$animateProvider.classNameFilter(validRegex);
292+
expect($animateProvider.classNameFilter()).toEqual(validRegex);
293+
294+
try { $animateProvider.classNameFilter(invalidRegex); } catch (err) {}
295+
expect($animateProvider.classNameFilter()).toBeNull();
296+
})
297+
);
298+
286299
it('should complete the leave DOM operation in case the classNameFilter fails', function() {
287300
module(function($animateProvider) {
288301
$animateProvider.classNameFilter(/memorable-animation/);

0 commit comments

Comments
 (0)