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

Commit a582e70

Browse files
committed
revert: fix(ngAnimate): throw an error if a callback is passed to animate methods
This reverts commit 9daa969.
1 parent 5f6194b commit a582e70

File tree

2 files changed

+0
-53
lines changed

2 files changed

+0
-53
lines changed

src/ng/animate.js

-14
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ var $animateMinErr = minErr('$animate');
44
var ELEMENT_NODE = 1;
55
var NG_ANIMATE_CLASSNAME = 'ng-animate';
66

7-
8-
function assertNoCallback(param) {
9-
if (isFunction(param)) {
10-
throw $animateMinErr('nocb', 'Do not pass a callback to animate methods');
11-
}
12-
}
13-
147
function mergeClasses(a,b) {
158
if (!a && !b) return '';
169
if (!a) return b;
@@ -423,7 +416,6 @@ var $AnimateProvider = ['$provide', function($provide) {
423416
* @return {Promise} the animation callback promise
424417
*/
425418
enter: function(element, parent, after, options) {
426-
assertNoCallback(options);
427419
parent = parent && jqLite(parent);
428420
after = after && jqLite(after);
429421
parent = parent || after.parent();
@@ -450,7 +442,6 @@ var $AnimateProvider = ['$provide', function($provide) {
450442
* @return {Promise} the animation callback promise
451443
*/
452444
move: function(element, parent, after, options) {
453-
assertNoCallback(options);
454445
parent = parent && jqLite(parent);
455446
after = after && jqLite(after);
456447
parent = parent || after.parent();
@@ -472,7 +463,6 @@ var $AnimateProvider = ['$provide', function($provide) {
472463
* @return {Promise} the animation callback promise
473464
*/
474465
leave: function(element, options) {
475-
assertNoCallback(options);
476466
return $$animateQueue.push(element, 'leave', options, function() {
477467
element.remove();
478468
});
@@ -497,7 +487,6 @@ var $AnimateProvider = ['$provide', function($provide) {
497487
* @return {Promise} the animation callback promise
498488
*/
499489
addClass: function(element, className, options) {
500-
assertNoCallback(options);
501490
options = options || {};
502491
options.addClass = mergeClasses(options.addclass, className);
503492
return $$animateQueue.push(element, 'addClass', options);
@@ -522,7 +511,6 @@ var $AnimateProvider = ['$provide', function($provide) {
522511
* @return {Promise} the animation callback promise
523512
*/
524513
removeClass: function(element, className, options) {
525-
assertNoCallback(options);
526514
options = options || {};
527515
options.removeClass = mergeClasses(options.removeClass, className);
528516
return $$animateQueue.push(element, 'removeClass', options);
@@ -548,7 +536,6 @@ var $AnimateProvider = ['$provide', function($provide) {
548536
* @return {Promise} the animation callback promise
549537
*/
550538
setClass: function(element, add, remove, options) {
551-
assertNoCallback(options);
552539
options = options || {};
553540
options.addClass = mergeClasses(options.addClass, add);
554541
options.removeClass = mergeClasses(options.removeClass, remove);
@@ -577,7 +564,6 @@ var $AnimateProvider = ['$provide', function($provide) {
577564
* @return {Promise} the animation callback promise
578565
*/
579566
animate: function(element, from, to, className, options) {
580-
assertNoCallback(options);
581567
options = options || {};
582568
options.from = options.from ? extend(options.from, from) : from;
583569
options.to = options.to ? extend(options.to, to) : to;

test/ngAnimate/animateSpec.js

-39
Original file line numberDiff line numberDiff line change
@@ -507,45 +507,6 @@ describe("animations", function() {
507507
});
508508
});
509509

510-
it('should throw an error when a callback function is passed as the options param', inject(function($animate, $rootScope, $document) {
511-
512-
var invalidCallback = function() { };
513-
var element = $document[0].createElement('div');
514-
element.setAttribute('id', 'crazy-man');
515-
516-
expect(function() {
517-
$animate.enter(element, parent, parent2, invalidCallback);
518-
}).toThrowMinErr('$animate', 'nocb', 'Do not pass a callback to animate methods');
519-
520-
expect(function() {
521-
$animate.move(element, parent, parent2, invalidCallback);
522-
}).toThrowMinErr('$animate', 'nocb', 'Do not pass a callback to animate methods');
523-
524-
parent.append(element);
525-
526-
expect(function() {
527-
$animate.addClass(element, 'klass', invalidCallback);
528-
}).toThrowMinErr('$animate', 'nocb', 'Do not pass a callback to animate methods');
529-
530-
element.className = 'klass';
531-
expect(function() {
532-
$animate.removeClass(element, 'klass', invalidCallback);
533-
}).toThrowMinErr('$animate', 'nocb', 'Do not pass a callback to animate methods');
534-
535-
expect(function() {
536-
$animate.setClass(element, 'one', 'two', invalidCallback);
537-
}).toThrowMinErr('$animate', 'nocb', 'Do not pass a callback to animate methods');
538-
539-
expect(function() {
540-
$animate.leave(element, invalidCallback);
541-
}).toThrowMinErr('$animate', 'nocb', 'Do not pass a callback to animate methods');
542-
543-
var toStyles = { color: 'red' };
544-
expect(function() {
545-
$animate.animate(element, {}, toStyles, 'klass', invalidCallback);
546-
}).toThrowMinErr('$animate', 'nocb', 'Do not pass a callback to animate methods');
547-
}));
548-
549510
describe('addClass / removeClass', function() {
550511
it('should not perform an animation if there are no valid CSS classes to add',
551512
inject(function($animate, $rootScope) {

0 commit comments

Comments
 (0)