From 53ec5e13e5955830b6751019eef232bd2125c0b6 Mon Sep 17 00:00:00 2001 From: Lucas Galfasó Date: Mon, 17 Feb 2014 13:02:58 +0100 Subject: fix($compile): support templates with thead and tfoot root elements If the first element in a template is a or a , then use the existing logic to handle table elements compilation. Closes #6289 --- test/ng/compileSpec.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'test') diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 98b1650f..5110c4d6 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -529,10 +529,18 @@ describe('$compile', function() { replace: true, template: 'TH' })); + directive('replaceWithThead', valueFn({ + replace: true, + template: 'TD' + })); directive('replaceWithTbody', valueFn({ replace: true, template: 'TD' })); + directive('replaceWithTfoot', valueFn({ + replace: true, + template: 'TD' + })); })); @@ -718,12 +726,26 @@ describe('$compile', function() { expect(nodeName_(element)).toMatch(/th/i); })); + it('should support templates with root tags', inject(function($compile, $rootScope) { + expect(function() { + element = $compile('
')($rootScope); + }).not.toThrow(); + expect(nodeName_(element)).toMatch(/thead/i); + })); + it('should support templates with root tags', inject(function($compile, $rootScope) { expect(function() { element = $compile('
')($rootScope); }).not.toThrow(); expect(nodeName_(element)).toMatch(/tbody/i); })); + + it('should support templates with root tags', inject(function($compile, $rootScope) { + expect(function() { + element = $compile('
')($rootScope); + }).not.toThrow(); + expect(nodeName_(element)).toMatch(/tfoot/i); + })); }); @@ -833,10 +855,18 @@ describe('$compile', function() { replace: true, templateUrl: 'th.html' })); + directive('replaceWithThead', valueFn({ + replace: true, + templateUrl: 'thead.html' + })); directive('replaceWithTbody', valueFn({ replace: true, templateUrl: 'tbody.html' })); + directive('replaceWithTfoot', valueFn({ + replace: true, + templateUrl: 'tfoot.html' + })); } )); @@ -1500,6 +1530,15 @@ describe('$compile', function() { expect(nodeName_(element)).toMatch(/th/i); })); + it('should support templates with root tags', inject(function($compile, $rootScope, $templateCache) { + $templateCache.put('thead.html', 'TD'); + expect(function() { + element = $compile('
')($rootScope); + }).not.toThrow(); + $rootScope.$digest(); + expect(nodeName_(element)).toMatch(/thead/i); + })); + it('should support templates with root tags', inject(function($compile, $rootScope, $templateCache) { $templateCache.put('tbody.html', 'TD'); expect(function() { @@ -1508,6 +1547,15 @@ describe('$compile', function() { $rootScope.$digest(); expect(nodeName_(element)).toMatch(/tbody/i); })); + + it('should support templates with root tags', inject(function($compile, $rootScope, $templateCache) { + $templateCache.put('tfoot.html', 'TD'); + expect(function() { + element = $compile('
')($rootScope); + }).not.toThrow(); + $rootScope.$digest(); + expect(nodeName_(element)).toMatch(/tfoot/i); + })); }); -- cgit v1.2.3