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 --- src/ng/compile.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/ng/compile.js b/src/ng/compile.js index 5b625c19..c7cd08bc 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -503,7 +503,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { Suffix = 'Directive', COMMENT_DIRECTIVE_REGEXP = /^\s*directive\:\s*([\d\w\-_]+)\s+(.*)$/, CLASS_DIRECTIVE_REGEXP = /(([\d\w\-_]+)(?:\:([^;]+))?;?)/, - TABLE_CONTENT_REGEXP = /^<\s*(tr|th|td|tbody)(\s+[^>]*)?>/i; + TABLE_CONTENT_REGEXP = /^<\s*(tr|th|td|thead|tbody|tfoot)(\s+[^>]*)?>/i; // Ref: http://developers.whatwg.org/webappapis.html#event-handler-idl-attributes // The assumption is that future DOM event attribute names will begin with @@ -1649,16 +1649,15 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { template = trim(template); if ((type = TABLE_CONTENT_REGEXP.exec(template))) { type = type[1].toLowerCase(); - var table = jqLite('' + template + '
'), - tbody = table.children('tbody'), - leaf = /(td|th)/.test(type) && table.find('tr'); - if (tbody.length && type !== 'tbody') { - table = tbody; + var table = jqLite('' + template + '
'); + if (/(thead|tbody|tfoot)/.test(type)) { + return table.children(type); } - if (leaf && leaf.length) { - table = leaf; + table = table.children('tbody'); + if (type === 'tr') { + return table.children('tr'); } - return table.contents(); + return table.children('tr').contents(); } return jqLite('
' + template + -- cgit v1.2.3