mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 11:37:38 +08:00
fix($compile): support templates with thead and tfoot root elements
If the first element in a template is a <thead> or a <tfoot>, then use the existing logic to handle table elements compilation. Closes #6289
This commit is contained in:
committed by
Brian Ford
parent
235731d32b
commit
53ec5e13e5
@@ -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('<table>' + template + '</table>'),
|
||||
tbody = table.children('tbody'),
|
||||
leaf = /(td|th)/.test(type) && table.find('tr');
|
||||
if (tbody.length && type !== 'tbody') {
|
||||
table = tbody;
|
||||
var table = jqLite('<table>' + template + '</table>');
|
||||
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('<div>' +
|
||||
template +
|
||||
|
||||
Reference in New Issue
Block a user