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

Unified Diff: pkg/mdv/lib/src/template_iterator.dart

Issue 19744006: Ensure model is passed with <template if> (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: add comment Created 7 years, 5 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 | « no previous file | pkg/mdv/test/template_element_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/mdv/lib/src/template_iterator.dart
diff --git a/pkg/mdv/lib/src/template_iterator.dart b/pkg/mdv/lib/src/template_iterator.dart
index a54a73a2df3ac835c5e0c8d07358526aa4fa9c5f..f2cb73f91a641266b24f1a1803b3694150f5155f 100644
--- a/pkg/mdv/lib/src/template_iterator.dart
+++ b/pkg/mdv/lib/src/template_iterator.dart
@@ -43,10 +43,21 @@ void _addBindings(Node node, model, [BindingDelegate delegate]) {
}
void _addAttributeBindings(Element element, model, delegate) {
- element.attributes.forEach((name, value) {
- if (value == '' && (name == 'bind' || name == 'repeat')) {
- value = '{{}}';
+ var attrs = new LinkedHashMap.from(element.attributes);
+ if (element.isTemplate) {
+ // Accept 'naked' bind & repeat.
+ if (attrs['bind'] == '') attrs['bind'] = '{{}}';
+ if (attrs['repeat'] == '') attrs['repeat'] = '{{}}';
+
+ // Treat <template if="{{expr}}"> as <template bind if="{{expr}}">
+ if (attrs.containsKey('if') &&
+ !attrs.containsKey('bind') &&
+ !attrs.containsKey('repeat')) {
+ attrs['bind'] = '{{}}';
}
+ }
+
+ attrs.forEach((name, value) {
_parseAndBind(element, name, value, model, delegate);
});
}
« no previous file with comments | « no previous file | pkg/mdv/test/template_element_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698