@@ -517,6 +517,22 @@ describe('$compile', function() {
517517 expect ( element ) . toBe ( attr . $$element ) ;
518518 }
519519 } ) ) ;
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+ } ) ) ;
520536 } ) ) ;
521537
522538
@@ -680,6 +696,34 @@ describe('$compile', function() {
680696 } ) . not . toThrow ( ) ;
681697 } ) ;
682698 } ) ;
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+ } ) ) ;
683727 } ) ;
684728
685729
@@ -776,6 +820,23 @@ describe('$compile', function() {
776820 replace : true ,
777821 template : '<span>Hello, {{name}}!</span>'
778822 } ) ) ;
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+ } ) ) ;
779840 }
780841 ) ) ;
781842
@@ -1411,6 +1472,42 @@ describe('$compile', function() {
14111472 expect ( element . html ( ) ) . toContain ( 'i = 1' ) ;
14121473 } ) ;
14131474 } ) ;
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+ } ) ) ;
14141511 } ) ;
14151512
14161513
0 commit comments