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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/mdv/test/template_element_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of mdv; 5 part of mdv;
6 6
7 // This code is a port of Model-Driven-Views: 7 // This code is a port of Model-Driven-Views:
8 // https://github.com/polymer-project/mdv 8 // https://github.com/polymer-project/mdv
9 // The code mostly comes from src/template_element.js 9 // The code mostly comes from src/template_element.js
10 10
(...skipping 25 matching lines...) Expand all
36 } else if (node is Text) { 36 } else if (node is Text) {
37 _parseAndBind(node, 'text', node.text, model, delegate); 37 _parseAndBind(node, 'text', node.text, model, delegate);
38 } 38 }
39 39
40 for (var c = node.firstChild; c != null; c = c.nextNode) { 40 for (var c = node.firstChild; c != null; c = c.nextNode) {
41 _addBindings(c, model, delegate); 41 _addBindings(c, model, delegate);
42 } 42 }
43 } 43 }
44 44
45 void _addAttributeBindings(Element element, model, delegate) { 45 void _addAttributeBindings(Element element, model, delegate) {
46 element.attributes.forEach((name, value) { 46 var attrs = new LinkedHashMap.from(element.attributes);
47 if (value == '' && (name == 'bind' || name == 'repeat')) { 47 if (element.isTemplate) {
48 value = '{{}}'; 48 // Accept 'naked' bind & repeat.
49 if (attrs['bind'] == '') attrs['bind'] = '{{}}';
50 if (attrs['repeat'] == '') attrs['repeat'] = '{{}}';
51 if (attrs.containsKey('if') &&
52 !attrs.containsKey('bind') &&
53 !attrs.containsKey('repeat')) {
Siggi Cherem (dart-lang) 2013/07/23 20:44:14 might be worth adding a small comment here. Initia
Jennifer Messerly 2013/07/23 22:12:00 Done.
54 attrs['bind'] = '{{}}';
49 } 55 }
56 }
57
58 attrs.forEach((name, value) {
50 _parseAndBind(element, name, value, model, delegate); 59 _parseAndBind(element, name, value, model, delegate);
51 }); 60 });
52 } 61 }
53 62
54 void _parseAndBind(Node node, String name, String text, model, 63 void _parseAndBind(Node node, String name, String text, model,
55 BindingDelegate delegate) { 64 BindingDelegate delegate) {
56 65
57 var tokens = _parseMustacheTokens(text); 66 var tokens = _parseMustacheTokens(text);
58 if (tokens.length == 0 || (tokens.length == 1 && tokens[0].isText)) { 67 if (tokens.length == 0 || (tokens.length == 1 && tokens[0].isText)) {
59 return; 68 return;
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 nodeExt._templateIterator = null; 382 nodeExt._templateIterator = null;
374 } 383 }
375 } 384 }
376 385
377 _nodeOrCustom(node).unbindAll(); 386 _nodeOrCustom(node).unbindAll();
378 for (var c = node.firstChild; c != null; c = c.nextNode) { 387 for (var c = node.firstChild; c != null; c = c.nextNode) {
379 _unbindAllRecursively(c); 388 _unbindAllRecursively(c);
380 } 389 }
381 } 390 }
382 } 391 }
OLDNEW
« 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