Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Unified Diff: lib/src/html_cleaner.dart

Issue 13592003: add support for template repeat (Closed) Base URL: https://github.com/dart-lang/web-ui.git@master
Patch Set: feedback Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/emitters.dart ('k') | lib/src/info.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/html_cleaner.dart
diff --git a/lib/src/html_cleaner.dart b/lib/src/html_cleaner.dart
index 84ff3e2b41ab11b33c0922feb612ac4d95050aa7..974cb6a41008028895cd991cf7d15a3a422ceaed 100644
--- a/lib/src/html_cleaner.dart
+++ b/lib/src/html_cleaner.dart
@@ -35,10 +35,27 @@ class _HtmlCleaner extends InfoVisitor {
info.removeAttributes.forEach(node.attributes.remove);
info.removeAttributes.clear();
- // Hide all template elements. At the very least, we must do this for
- // template attributes, such as `<td template if="cond">`.
- if (info.hasIfCondition && !info.isTemplateElement) {
- node.attributes['style'] = 'display:none';
+
+ // Normally, <template> nodes hang around in the DOM as placeholders, and
+ // the user-agent style specifies that they are hidden. For browsers without
+ // native template, we inject the style later.
+ //
+ // However, template *attributes* are used for things like this:
+ // * <td template if="condition">
+ // * <td template repeat="x in list">
+ //
+ // In this case, we'll leave the TD as a placeholder. So hide it.
+ //
+ // For now, we also support this:
+ // * <tr template iterate="x in list">
+ //
+ // We don't need to hide this node, because its children are expanded as
+ // child nodes.
+ if (info is TemplateInfo) {
+ TemplateInfo t = info;
+ if (!t.isTemplateElement && (t.hasCondition || t.isRepeat)) {
+ node.attributes['style'] = 'display:none';
+ }
}
if (info.childrenCreatedInCode) {
« no previous file with comments | « lib/src/emitters.dart ('k') | lib/src/info.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698