1
1
/**
2
- * @license AngularJS v1.5.3
2
+ * @license AngularJS v1.5.5
3
3
* (c) 2010-2016 Google, Inc. http://angularjs.org
4
4
* License: MIT
5
5
*/
6
- ( function ( window , angular , undefined ) { 'use strict' ;
6
+ ( function ( window , angular ) { 'use strict' ;
7
7
8
8
/* jshint ignore:start */
9
9
var noop = angular . noop ;
@@ -2317,7 +2317,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
2317
2317
}
2318
2318
2319
2319
// IE9-11 has no method "contains" in SVG element and in Node.prototype. Bug #10259.
2320
- var contains = Node . prototype . contains || function ( arg ) {
2320
+ var contains = window . Node . prototype . contains || function ( arg ) {
2321
2321
// jshint bitwise: false
2322
2322
return this === arg || ! ! ( this . compareDocumentPosition ( arg ) & 16 ) ;
2323
2323
// jshint bitwise: true
@@ -2342,6 +2342,23 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
2342
2342
return matches ;
2343
2343
}
2344
2344
2345
+ function filterFromRegistry ( list , matchContainer , matchCallback ) {
2346
+ var containerNode = extractElementNode ( matchContainer ) ;
2347
+ return list . filter ( function ( entry ) {
2348
+ var isMatch = entry . node === containerNode &&
2349
+ ( ! matchCallback || entry . callback === matchCallback ) ;
2350
+ return ! isMatch ;
2351
+ } ) ;
2352
+ }
2353
+
2354
+ function cleanupEventListeners ( phase , element ) {
2355
+ if ( phase === 'close' && ! element [ 0 ] . parentNode ) {
2356
+ // If the element is not attached to a parentNode, it has been removed by
2357
+ // the domOperation, and we can safely remove the event callbacks
2358
+ $animate . off ( element ) ;
2359
+ }
2360
+ }
2361
+
2345
2362
var $animate = {
2346
2363
on : function ( event , container , callback ) {
2347
2364
var node = extractElementNode ( container ) ;
@@ -2353,26 +2370,33 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
2353
2370
2354
2371
// Remove the callback when the element is removed from the DOM
2355
2372
jqLite ( container ) . on ( '$destroy' , function ( ) {
2356
- $animate . off ( event , container , callback ) ;
2373
+ var animationDetails = activeAnimationsLookup . get ( node ) ;
2374
+
2375
+ if ( ! animationDetails ) {
2376
+ // If there's an animation ongoing, the callback calling code will remove
2377
+ // the event listeners. If we'd remove here, the callbacks would be removed
2378
+ // before the animation ends
2379
+ $animate . off ( event , container , callback ) ;
2380
+ }
2357
2381
} ) ;
2358
2382
} ,
2359
2383
2360
2384
off : function ( event , container , callback ) {
2385
+ if ( arguments . length === 1 && ! angular . isString ( arguments [ 0 ] ) ) {
2386
+ container = arguments [ 0 ] ;
2387
+ for ( var eventType in callbackRegistry ) {
2388
+ callbackRegistry [ eventType ] = filterFromRegistry ( callbackRegistry [ eventType ] , container ) ;
2389
+ }
2390
+
2391
+ return ;
2392
+ }
2393
+
2361
2394
var entries = callbackRegistry [ event ] ;
2362
2395
if ( ! entries ) return ;
2363
2396
2364
2397
callbackRegistry [ event ] = arguments . length === 1
2365
2398
? null
2366
2399
: filterFromRegistry ( entries , container , callback ) ;
2367
-
2368
- function filterFromRegistry ( list , matchContainer , matchCallback ) {
2369
- var containerNode = extractElementNode ( matchContainer ) ;
2370
- return list . filter ( function ( entry ) {
2371
- var isMatch = entry . node === containerNode &&
2372
- ( ! matchCallback || entry . callback === matchCallback ) ;
2373
- return ! isMatch ;
2374
- } ) ;
2375
- }
2376
2400
} ,
2377
2401
2378
2402
pin : function ( element , parentElement ) {
@@ -2486,12 +2510,14 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
2486
2510
2487
2511
var isStructural = [ 'enter' , 'move' , 'leave' ] . indexOf ( event ) >= 0 ;
2488
2512
2513
+ var documentHidden = $document [ 0 ] . hidden ;
2514
+
2489
2515
// this is a hard disable of all animations for the application or on
2490
2516
// the element itself, therefore there is no need to continue further
2491
2517
// past this point if not enabled
2492
2518
// Animations are also disabled if the document is currently hidden (page is not visible
2493
2519
// to the user), because browsers slow down or do not flush calls to requestAnimationFrame
2494
- var skipAnimations = ! animationsEnabled || $document [ 0 ] . hidden || disabledElementsLookup . get ( node ) ;
2520
+ var skipAnimations = ! animationsEnabled || documentHidden || disabledElementsLookup . get ( node ) ;
2495
2521
var existingAnimation = ( ! skipAnimations && activeAnimationsLookup . get ( node ) ) || { } ;
2496
2522
var hasExistingAnimation = ! ! existingAnimation . state ;
2497
2523
@@ -2502,7 +2528,10 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
2502
2528
}
2503
2529
2504
2530
if ( skipAnimations ) {
2531
+ // Callbacks should fire even if the document is hidden (regression fix for issue #14120)
2532
+ if ( documentHidden ) notifyProgress ( runner , event , 'start' ) ;
2505
2533
close ( ) ;
2534
+ if ( documentHidden ) notifyProgress ( runner , event , 'close' ) ;
2506
2535
return runner ;
2507
2536
}
2508
2537
@@ -2652,6 +2681,11 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
2652
2681
markElementAnimationState ( element , RUNNING_STATE ) ;
2653
2682
var realRunner = $$animation ( element , event , animationDetails . options ) ;
2654
2683
2684
+ // this will update the runner's flow-control events based on
2685
+ // the `realRunner` object.
2686
+ runner . setHost ( realRunner ) ;
2687
+ notifyProgress ( runner , event , 'start' , { } ) ;
2688
+
2655
2689
realRunner . done ( function ( status ) {
2656
2690
close ( ! status ) ;
2657
2691
var animationDetails = activeAnimationsLookup . get ( node ) ;
@@ -2660,11 +2694,6 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
2660
2694
}
2661
2695
notifyProgress ( runner , event , 'close' , { } ) ;
2662
2696
} ) ;
2663
-
2664
- // this will update the runner's flow-control events based on
2665
- // the `realRunner` object.
2666
- runner . setHost ( realRunner ) ;
2667
- notifyProgress ( runner , event , 'start' , { } ) ;
2668
2697
} ) ;
2669
2698
2670
2699
return runner ;
@@ -2681,7 +2710,10 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
2681
2710
forEach ( callbacks , function ( callback ) {
2682
2711
callback ( element , phase , data ) ;
2683
2712
} ) ;
2713
+ cleanupEventListeners ( phase , element ) ;
2684
2714
} ) ;
2715
+ } else {
2716
+ cleanupEventListeners ( phase , element ) ;
2685
2717
}
2686
2718
} ) ;
2687
2719
runner . progress ( event , phase , data ) ;
@@ -3486,7 +3518,7 @@ var ngAnimateSwapDirective = ['$animate', '$rootScope', function($animate, $root
3486
3518
* <div ng-show="bool" class="fade">
3487
3519
* Show and hide me
3488
3520
* </div>
3489
- * <button ng-click="bool=true ">Toggle</button>
3521
+ * <button ng-click="bool=!bool ">Toggle</button>
3490
3522
*
3491
3523
* <style>
3492
3524
* .fade.ng-hide {
0 commit comments