diff options
| author | Caitlin Potter | 2013-12-02 15:05:21 -0500 | 
|---|---|---|
| committer | Caitlin Potter | 2014-02-14 14:42:55 -0500 | 
| commit | 31c450bcee53d0a3827b7e0a611e9013b2496506 (patch) | |
| tree | 947ca3b89b4153705fe4a2c163672c8d07eb5d18 /test | |
| parent | a9fcb0d0fc6456f80501b8820d02b04d7c15b6d6 (diff) | |
| download | angular.js-31c450bcee53d0a3827b7e0a611e9013b2496506.tar.bz2 | |
fix($compile) support templates with table content root nodes
If the first element in a template is a <tr>, <th>, <td>, or <tbody> tag,
the HTML compiler will ensure that the template is wrapped in a <table>
element so that the table content is not discarded.
Closes #2848
Closes #1459
Closes #3647
Closes #3241
Diffstat (limited to 'test')
| -rwxr-xr-x | test/ng/compileSpec.js | 97 | 
1 files changed, 97 insertions, 0 deletions
| diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 60b1024b..e9ab15e4 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -517,6 +517,22 @@ describe('$compile', function() {                expect(element).toBe(attr.$$element);              }            })); +          directive('replaceWithTr', valueFn({ +            replace: true, +            template: '<tr><td>TR</td></tr>' +          })); +          directive('replaceWithTd', valueFn({ +            replace: true, +            template: '<td>TD</td>' +          })); +          directive('replaceWithTh', valueFn({ +            replace: true, +            template: '<th>TH</th>' +          })); +          directive('replaceWithTbody', valueFn({ +            replace: true, +            template: '<tbody><tr><td>TD</td></tr></tbody>' +          }));          })); @@ -680,6 +696,34 @@ describe('$compile', function() {              }).not.toThrow();            });          }); + +        it('should support templates with root <tr> tags', inject(function($compile, $rootScope) { +          expect(function() { +            element = $compile('<div replace-with-tr></div>')($rootScope); +          }).not.toThrow(); +          expect(nodeName_(element)).toMatch(/tr/i); +        })); + +        it('should support templates with root <td> tags', inject(function($compile, $rootScope) { +          expect(function() { +            element = $compile('<div replace-with-td></div>')($rootScope); +          }).not.toThrow(); +          expect(nodeName_(element)).toMatch(/td/i); +        })); + +        it('should support templates with root <th> tags', inject(function($compile, $rootScope) { +          expect(function() { +            element = $compile('<div replace-with-th></div>')($rootScope); +          }).not.toThrow(); +          expect(nodeName_(element)).toMatch(/th/i); +        })); + +        it('should support templates with root <tbody> tags', inject(function($compile, $rootScope) { +          expect(function() { +            element = $compile('<div replace-with-tbody></div>')($rootScope); +          }).not.toThrow(); +          expect(nodeName_(element)).toMatch(/tbody/i); +        }));        }); @@ -776,6 +820,23 @@ describe('$compile', function() {                replace: true,                template: '<span>Hello, {{name}}!</span>'              })); + +            directive('replaceWithTr', valueFn({ +              replace: true, +              templateUrl: 'tr.html' +            })); +            directive('replaceWithTd', valueFn({ +              replace: true, +              templateUrl: 'td.html' +            })); +            directive('replaceWithTh', valueFn({ +              replace: true, +              templateUrl: 'th.html' +            })); +            directive('replaceWithTbody', valueFn({ +              replace: true, +              templateUrl: 'tbody.html' +            }));            }          )); @@ -1411,6 +1472,42 @@ describe('$compile', function() {              expect(element.html()).toContain('i = 1');            });          }); + +        it('should support templates with root <tr> tags', inject(function($compile, $rootScope, $templateCache) { +          $templateCache.put('tr.html', '<tr><td>TR</td></tr>'); +          expect(function() { +            element = $compile('<div replace-with-tr></div>')($rootScope); +          }).not.toThrow(); +          $rootScope.$digest(); +          expect(nodeName_(element)).toMatch(/tr/i); +        })); + +        it('should support templates with root <td> tags', inject(function($compile, $rootScope, $templateCache) { +          $templateCache.put('td.html', '<td>TD</td>'); +          expect(function() { +            element = $compile('<div replace-with-td></div>')($rootScope); +          }).not.toThrow(); +          $rootScope.$digest(); +          expect(nodeName_(element)).toMatch(/td/i); +        })); + +        it('should support templates with root <th> tags', inject(function($compile, $rootScope, $templateCache) { +          $templateCache.put('th.html', '<th>TH</th>'); +          expect(function() { +            element = $compile('<div replace-with-th></div>')($rootScope); +          }).not.toThrow(); +          $rootScope.$digest(); +          expect(nodeName_(element)).toMatch(/th/i); +        })); + +        it('should support templates with root <tbody> tags', inject(function($compile, $rootScope, $templateCache) { +          $templateCache.put('tbody.html', '<tbody><tr><td>TD</td></tr></tbody>'); +          expect(function() { +            element = $compile('<div replace-with-tbody></div>')($rootScope); +          }).not.toThrow(); +          $rootScope.$digest(); +          expect(nodeName_(element)).toMatch(/tbody/i); +        }));        }); | 
