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

Commit b2f79fe

Browse files
committed
fix($animate): reset classNameFilter to null when a disallowed RegExp is used
1 parent 012319d commit b2f79fe

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
@@ -242,6 +242,7 @@ var $AnimateProvider = ['$provide', function($provide) {
242242
if (classNameFilter) {
243243
var reservedRegex = new RegExp('[(\\s|\\/)]' + NG_ANIMATE_CLASSNAME + '[(\\s|\\/)]');
244244
if (reservedRegex.test(classNameFilter.toString())) {
245+
classNameFilter = null;
245246
throw $animateMinErr('nongcls', '$animateProvider.classNameFilter(regex) prohibits accepting a regex value which matches/contains the "{0}" CSS class.', NG_ANIMATE_CLASSNAME);
246247
}
247248
}

test/ngAnimate/animateSpec.js

+13
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,19 @@ describe("animations", function() {
280280
})
281281
);
282282

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

0 commit comments

Comments
 (0)