@@ -100,15 +100,15 @@ var $AnimateProvider = ['$provide', function($provide) {
100
100
return defer . promise ;
101
101
}
102
102
103
- function resolveElementClasses ( element , cache ) {
103
+ function resolveElementClasses ( element , classes ) {
104
104
var toAdd = [ ] , toRemove = [ ] ;
105
105
106
106
var hasClasses = createMap ( ) ;
107
107
forEach ( ( element . attr ( 'class' ) || '' ) . split ( / \s + / ) , function ( className ) {
108
108
hasClasses [ className ] = true ;
109
109
} ) ;
110
110
111
- forEach ( cache . classes , function ( status , className ) {
111
+ forEach ( classes , function ( status , className ) {
112
112
var hasClass = hasClasses [ className ] ;
113
113
114
114
// If the most recent class manipulation (via $animate) was to remove the class, and the
@@ -288,20 +288,12 @@ var $AnimateProvider = ['$provide', function($provide) {
288
288
* @param {string } remove the CSS class which will be removed from the element
289
289
* @return {Promise } the animation callback promise
290
290
*/
291
- setClass : function ( element , add , remove , runSynchronously ) {
291
+ setClass : function ( element , add , remove ) {
292
292
var self = this ;
293
293
var STORAGE_KEY = '$$animateClasses' ;
294
294
var createdCache = false ;
295
295
element = jqLite ( element ) ;
296
296
297
- if ( runSynchronously ) {
298
- // TODO(@caitp/@matsko): Remove undocumented `runSynchronously` parameter, and always
299
- // perform DOM manipulation asynchronously or in postDigest.
300
- self . $$addClassImmediately ( element , add ) ;
301
- self . $$removeClassImmediately ( element , remove ) ;
302
- return asyncPromise ( ) ;
303
- }
304
-
305
297
var cache = element . data ( STORAGE_KEY ) ;
306
298
if ( ! cache ) {
307
299
cache = {
@@ -322,11 +314,14 @@ var $AnimateProvider = ['$provide', function($provide) {
322
314
var cache = element . data ( STORAGE_KEY ) ;
323
315
element . removeData ( STORAGE_KEY ) ;
324
316
325
- var classes = cache && resolveElementClasses ( element , cache ) ;
326
-
327
- if ( classes ) {
328
- if ( classes [ 0 ] ) self . $$addClassImmediately ( element , classes [ 0 ] ) ;
329
- if ( classes [ 1 ] ) self . $$removeClassImmediately ( element , classes [ 1 ] ) ;
317
+ // in the event that the element is removed before postDigest
318
+ // is run then the cache will be undefined and there will be
319
+ // no need anymore to add or remove and of the element classes
320
+ if ( cache ) {
321
+ var classes = resolveElementClasses ( element , cache . classes ) ;
322
+ if ( classes ) {
323
+ self . $$setClassImmediately ( element , classes [ 0 ] , classes [ 1 ] ) ;
324
+ }
330
325
}
331
326
332
327
done ( ) ;
@@ -337,6 +332,12 @@ var $AnimateProvider = ['$provide', function($provide) {
337
332
return cache . promise ;
338
333
} ,
339
334
335
+ $$setClassImmediately : function ( element , add , remove ) {
336
+ add && this . $$addClassImmediately ( element , add ) ;
337
+ remove && this . $$removeClassImmediately ( element , remove ) ;
338
+ return asyncPromise ( ) ;
339
+ } ,
340
+
340
341
enabled : noop ,
341
342
cancel : noop
342
343
} ;
0 commit comments