@@ -517,6 +517,22 @@ describe('$compile', function() {
517
517
expect ( element ) . toBe ( attr . $$element ) ;
518
518
}
519
519
} ) ) ;
520
+ directive ( 'replaceWithTr' , valueFn ( {
521
+ replace : true ,
522
+ template : '<tr><td>TR</td></tr>'
523
+ } ) ) ;
524
+ directive ( 'replaceWithTd' , valueFn ( {
525
+ replace : true ,
526
+ template : '<td>TD</td>'
527
+ } ) ) ;
528
+ directive ( 'replaceWithTh' , valueFn ( {
529
+ replace : true ,
530
+ template : '<th>TH</th>'
531
+ } ) ) ;
532
+ directive ( 'replaceWithTbody' , valueFn ( {
533
+ replace : true ,
534
+ template : '<tbody><tr><td>TD</td></tr></tbody>'
535
+ } ) ) ;
520
536
} ) ) ;
521
537
522
538
@@ -680,6 +696,34 @@ describe('$compile', function() {
680
696
} ) . not . toThrow ( ) ;
681
697
} ) ;
682
698
} ) ;
699
+
700
+ it ( 'should support templates with root <tr> tags' , inject ( function ( $compile , $rootScope ) {
701
+ expect ( function ( ) {
702
+ element = $compile ( '<div replace-with-tr></div>' ) ( $rootScope ) ;
703
+ } ) . not . toThrow ( ) ;
704
+ expect ( nodeName_ ( element ) ) . toMatch ( / t r / i) ;
705
+ } ) ) ;
706
+
707
+ it ( 'should support templates with root <td> tags' , inject ( function ( $compile , $rootScope ) {
708
+ expect ( function ( ) {
709
+ element = $compile ( '<div replace-with-td></div>' ) ( $rootScope ) ;
710
+ } ) . not . toThrow ( ) ;
711
+ expect ( nodeName_ ( element ) ) . toMatch ( / t d / i) ;
712
+ } ) ) ;
713
+
714
+ it ( 'should support templates with root <th> tags' , inject ( function ( $compile , $rootScope ) {
715
+ expect ( function ( ) {
716
+ element = $compile ( '<div replace-with-th></div>' ) ( $rootScope ) ;
717
+ } ) . not . toThrow ( ) ;
718
+ expect ( nodeName_ ( element ) ) . toMatch ( / t h / i) ;
719
+ } ) ) ;
720
+
721
+ it ( 'should support templates with root <tbody> tags' , inject ( function ( $compile , $rootScope ) {
722
+ expect ( function ( ) {
723
+ element = $compile ( '<div replace-with-tbody></div>' ) ( $rootScope ) ;
724
+ } ) . not . toThrow ( ) ;
725
+ expect ( nodeName_ ( element ) ) . toMatch ( / t b o d y / i) ;
726
+ } ) ) ;
683
727
} ) ;
684
728
685
729
@@ -776,6 +820,23 @@ describe('$compile', function() {
776
820
replace : true ,
777
821
template : '<span>Hello, {{name}}!</span>'
778
822
} ) ) ;
823
+
824
+ directive ( 'replaceWithTr' , valueFn ( {
825
+ replace : true ,
826
+ templateUrl : 'tr.html'
827
+ } ) ) ;
828
+ directive ( 'replaceWithTd' , valueFn ( {
829
+ replace : true ,
830
+ templateUrl : 'td.html'
831
+ } ) ) ;
832
+ directive ( 'replaceWithTh' , valueFn ( {
833
+ replace : true ,
834
+ templateUrl : 'th.html'
835
+ } ) ) ;
836
+ directive ( 'replaceWithTbody' , valueFn ( {
837
+ replace : true ,
838
+ templateUrl : 'tbody.html'
839
+ } ) ) ;
779
840
}
780
841
) ) ;
781
842
@@ -1411,6 +1472,42 @@ describe('$compile', function() {
1411
1472
expect ( element . html ( ) ) . toContain ( 'i = 1' ) ;
1412
1473
} ) ;
1413
1474
} ) ;
1475
+
1476
+ it ( 'should support templates with root <tr> tags' , inject ( function ( $compile , $rootScope , $templateCache ) {
1477
+ $templateCache . put ( 'tr.html' , '<tr><td>TR</td></tr>' ) ;
1478
+ expect ( function ( ) {
1479
+ element = $compile ( '<div replace-with-tr></div>' ) ( $rootScope ) ;
1480
+ } ) . not . toThrow ( ) ;
1481
+ $rootScope . $digest ( ) ;
1482
+ expect ( nodeName_ ( element ) ) . toMatch ( / t r / i) ;
1483
+ } ) ) ;
1484
+
1485
+ it ( 'should support templates with root <td> tags' , inject ( function ( $compile , $rootScope , $templateCache ) {
1486
+ $templateCache . put ( 'td.html' , '<td>TD</td>' ) ;
1487
+ expect ( function ( ) {
1488
+ element = $compile ( '<div replace-with-td></div>' ) ( $rootScope ) ;
1489
+ } ) . not . toThrow ( ) ;
1490
+ $rootScope . $digest ( ) ;
1491
+ expect ( nodeName_ ( element ) ) . toMatch ( / t d / i) ;
1492
+ } ) ) ;
1493
+
1494
+ it ( 'should support templates with root <th> tags' , inject ( function ( $compile , $rootScope , $templateCache ) {
1495
+ $templateCache . put ( 'th.html' , '<th>TH</th>' ) ;
1496
+ expect ( function ( ) {
1497
+ element = $compile ( '<div replace-with-th></div>' ) ( $rootScope ) ;
1498
+ } ) . not . toThrow ( ) ;
1499
+ $rootScope . $digest ( ) ;
1500
+ expect ( nodeName_ ( element ) ) . toMatch ( / t h / i) ;
1501
+ } ) ) ;
1502
+
1503
+ it ( 'should support templates with root <tbody> tags' , inject ( function ( $compile , $rootScope , $templateCache ) {
1504
+ $templateCache . put ( 'tbody.html' , '<tbody><tr><td>TD</td></tr></tbody>' ) ;
1505
+ expect ( function ( ) {
1506
+ element = $compile ( '<div replace-with-tbody></div>' ) ( $rootScope ) ;
1507
+ } ) . not . toThrow ( ) ;
1508
+ $rootScope . $digest ( ) ;
1509
+ expect ( nodeName_ ( element ) ) . toMatch ( / t b o d y / i) ;
1510
+ } ) ) ;
1414
1511
} ) ;
1415
1512
1416
1513
0 commit comments