File tree 2 files changed +25
-3
lines changed
2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -503,7 +503,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
503
503
Suffix = 'Directive' ,
504
504
COMMENT_DIRECTIVE_REGEXP = / ^ \s * d i r e c t i v e \: \s * ( [ \d \w \- _ ] + ) \s + ( .* ) $ / ,
505
505
CLASS_DIRECTIVE_REGEXP = / ( ( [ \d \w \- _ ] + ) (?: \: ( [ ^ ; ] + ) ) ? ; ? ) / ,
506
- TABLE_CONTENT_REGEXP = / ^ < \s * ( t r | t h | t d | t b o d y ) ( \s + [ ^ > ] * ) ? > / i;
506
+ TABLE_CONTENT_REGEXP = / ^ < \s * ( t r | t h | t d | t h e a d | t b o d y | t f o o t ) ( \s + [ ^ > ] * ) ? > / i;
507
507
508
508
// Ref: http://developers.whatwg.org/webappapis.html#event-handler-idl-attributes
509
509
// The assumption is that future DOM event attribute names will begin with
@@ -1651,8 +1651,8 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
1651
1651
type = type [ 1 ] . toLowerCase ( ) ;
1652
1652
var table = jqLite ( '<table>' + template + '</table>' ) ,
1653
1653
tbody = table . children ( 'tbody' ) ,
1654
- leaf = / ( t d | t h ) / . test ( type ) && table . find ( 'tr' ) ;
1655
- if ( tbody . length && type !== ' tbody' ) {
1654
+ leaf = / ( t d | t h ) $ / . test ( type ) && table . find ( 'tr' ) ;
1655
+ if ( tbody . length && ! / ( t h e a d | t b o d y | t f o o t ) / . test ( type ) ) {
1656
1656
table = tbody ;
1657
1657
}
1658
1658
if ( leaf && leaf . length ) {
Original file line number Diff line number Diff line change @@ -529,10 +529,18 @@ describe('$compile', function() {
529
529
replace : true ,
530
530
template : '<th>TH</th>'
531
531
} ) ) ;
532
+ directive ( 'replaceWithThead' , valueFn ( {
533
+ replace : true ,
534
+ template : '<thead><tr><td>TD</td></tr></thead>'
535
+ } ) ) ;
532
536
directive ( 'replaceWithTbody' , valueFn ( {
533
537
replace : true ,
534
538
template : '<tbody><tr><td>TD</td></tr></tbody>'
535
539
} ) ) ;
540
+ directive ( 'replaceWithTfoot' , valueFn ( {
541
+ replace : true ,
542
+ template : '<tfoot><tr><td>TD</td></tr></tfoot>'
543
+ } ) ) ;
536
544
} ) ) ;
537
545
538
546
@@ -718,12 +726,26 @@ describe('$compile', function() {
718
726
expect ( nodeName_ ( element ) ) . toMatch ( / t h / i) ;
719
727
} ) ) ;
720
728
729
+ it ( 'should support templates with root <thead> tags' , inject ( function ( $compile , $rootScope ) {
730
+ expect ( function ( ) {
731
+ element = $compile ( '<div replace-with-thead></div>' ) ( $rootScope ) ;
732
+ } ) . not . toThrow ( ) ;
733
+ expect ( nodeName_ ( element ) ) . toMatch ( / t h e a d / i) ;
734
+ } ) ) ;
735
+
721
736
it ( 'should support templates with root <tbody> tags' , inject ( function ( $compile , $rootScope ) {
722
737
expect ( function ( ) {
723
738
element = $compile ( '<div replace-with-tbody></div>' ) ( $rootScope ) ;
724
739
} ) . not . toThrow ( ) ;
725
740
expect ( nodeName_ ( element ) ) . toMatch ( / t b o d y / i) ;
726
741
} ) ) ;
742
+
743
+ it ( 'should support templates with root <tfoot> tags' , inject ( function ( $compile , $rootScope ) {
744
+ expect ( function ( ) {
745
+ element = $compile ( '<div replace-with-tfoot></div>' ) ( $rootScope ) ;
746
+ } ) . not . toThrow ( ) ;
747
+ expect ( nodeName_ ( element ) ) . toMatch ( / t f o o t / i) ;
748
+ } ) ) ;
727
749
} ) ;
728
750
729
751
You can’t perform that action at this time.
0 commit comments