Skip to content

Commit d7206c1

Browse files
gkalpakellimist
authored andcommitted
fix($animate): reset classNameFilter to null when a disallowed RegExp is used
Closes angular#14913
1 parent ec8489c commit d7206c1

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-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

+14
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,20 @@ describe('animations', function() {
277277
})
278278
);
279279

280+
it('should clear the `classNameFilter` if a disallowed RegExp is passed',
281+
module(function($animateProvider) {
282+
var validRegex = /no-ng-animate/;
283+
var invalidRegex = /no ng-animate/;
284+
285+
$animateProvider.classNameFilter(validRegex);
286+
expect($animateProvider.classNameFilter()).toEqual(validRegex);
287+
288+
// eslint-disable-next-line no-empty
289+
try { $animateProvider.classNameFilter(invalidRegex); } catch (err) {}
290+
expect($animateProvider.classNameFilter()).toBeNull();
291+
})
292+
);
293+
280294
it('should complete the leave DOM operation in case the classNameFilter fails', function() {
281295
module(function($animateProvider) {
282296
$animateProvider.classNameFilter(/memorable-animation/);

0 commit comments

Comments
 (0)