@@ -1425,28 +1425,46 @@ describe("animations", function() {
1425
1425
} ) ) ;
1426
1426
1427
1427
1428
- it ( 'should allow an element to be pinned elsewhere and still be available in animations' ,
1429
- inject ( function ( $animate , $compile , $document , $rootElement , $rootScope ) {
1428
+ they ( 'should animate an element inside a pinned element that is the $prop element' ,
1429
+ [ 'same' , 'parent' , 'grandparent' ] ,
1430
+ function ( elementRelation ) {
1431
+ inject ( function ( $animate , $compile , $document , $rootElement , $rootScope ) {
1430
1432
1431
- var innerParent = jqLite ( '<div></div>' ) ;
1432
- jqLite ( $document [ 0 ] . body ) . append ( innerParent ) ;
1433
- innerParent . append ( $rootElement ) ;
1433
+ var pinElement , animateElement ;
1434
1434
1435
- var element = jqLite ( '<div></div>' ) ;
1436
- jqLite ( $document [ 0 ] . body ) . append ( element ) ;
1435
+ var innerParent = jqLite ( '<div></div>' ) ;
1436
+ jqLite ( $document [ 0 ] . body ) . append ( innerParent ) ;
1437
+ innerParent . append ( $rootElement ) ;
1437
1438
1438
- $animate . addClass ( element , 'red' ) ;
1439
- $rootScope . $digest ( ) ;
1440
- expect ( capturedAnimation ) . toBeFalsy ( ) ;
1439
+ switch ( elementRelation ) {
1440
+ case 'same' :
1441
+ pinElement = jqLite ( '<div id="animate"></div>' ) ;
1442
+ break ;
1443
+ case 'parent' :
1444
+ pinElement = jqLite ( '<div><div id="animate"></div></div>' ) ;
1445
+ break ;
1446
+ case 'grandparent' :
1447
+ pinElement = jqLite ( '<div><div><div id="animate"></div></div></div>' ) ;
1448
+ break ;
1449
+ }
1441
1450
1442
- $animate . pin ( element , $rootElement ) ;
1451
+ jqLite ( $document [ 0 ] . body ) . append ( pinElement ) ;
1452
+ animateElement = jqLite ( $document [ 0 ] . getElementById ( 'animate' ) ) ;
1443
1453
1444
- $animate . addClass ( element , 'blue ' ) ;
1445
- $rootScope . $digest ( ) ;
1446
- expect ( capturedAnimation ) . toBeTruthy ( ) ;
1454
+ $animate . addClass ( animateElement , 'red ' ) ;
1455
+ $rootScope . $digest ( ) ;
1456
+ expect ( capturedAnimation ) . toBeFalsy ( ) ;
1447
1457
1448
- dealoc ( element ) ;
1449
- } ) ) ;
1458
+ // Pin the element to the app root to enable animations
1459
+ $animate . pin ( pinElement , $rootElement ) ;
1460
+
1461
+ $animate . addClass ( animateElement , 'blue' ) ;
1462
+ $rootScope . $digest ( ) ;
1463
+ expect ( capturedAnimation ) . toBeTruthy ( ) ;
1464
+
1465
+ dealoc ( pinElement ) ;
1466
+ } ) ;
1467
+ } ) ;
1450
1468
1451
1469
it ( 'should adhere to the disabled state of the hosted parent when an element is pinned' ,
1452
1470
inject ( function ( $animate , $compile , $document , $rootElement , $rootScope ) {
0 commit comments