OLD | NEW |
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 bool _isSimpleBinding(List<String> tokens) => | 152 bool _isSimpleBinding(List<String> tokens) => |
153 tokens.length == 3 && tokens[0].isEmpty && tokens[2].isEmpty; | 153 tokens.length == 3 && tokens[0].isEmpty && tokens[2].isEmpty; |
154 | 154 |
155 /** | 155 /** |
156 * Parses {{ mustache }} bindings. | 156 * Parses {{ mustache }} bindings. |
157 * | 157 * |
158 * Returns null if there are no matches. Otherwise returns | 158 * Returns null if there are no matches. Otherwise returns |
159 * [TEXT, (PATH, TEXT)+] if there is at least one mustache. | 159 * [TEXT, (PATH, TEXT)+] if there is at least one mustache. |
160 */ | 160 */ |
161 List<String> _parseMustacheTokens(String s) { | 161 List<String> _parseMustacheTokens(String s) { |
162 if (s.isEmpty) return; | 162 if (s.isEmpty) return null; |
163 | 163 |
164 var tokens = null; | 164 var tokens = null; |
165 var length = s.length; | 165 var length = s.length; |
166 var startIndex = 0, lastIndex = 0, endIndex = 0; | 166 var startIndex = 0, lastIndex = 0, endIndex = 0; |
167 while (lastIndex < length) { | 167 while (lastIndex < length) { |
168 startIndex = s.indexOf('{{', lastIndex); | 168 startIndex = s.indexOf('{{', lastIndex); |
169 endIndex = startIndex < 0 ? -1 : s.indexOf('}}', startIndex + 2); | 169 endIndex = startIndex < 0 ? -1 : s.indexOf('}}', startIndex + 2); |
170 | 170 |
171 if (endIndex < 0) { | 171 if (endIndex < 0) { |
172 if (tokens == null) return null; | 172 if (tokens == null) return null; |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 nodeExt._templateIterator = null; | 401 nodeExt._templateIterator = null; |
402 } | 402 } |
403 } | 403 } |
404 | 404 |
405 _nodeOrCustom(node).unbindAll(); | 405 _nodeOrCustom(node).unbindAll(); |
406 for (var c = node.firstChild; c != null; c = c.nextNode) { | 406 for (var c = node.firstChild; c != null; c = c.nextNode) { |
407 _unbindAllRecursively(c); | 407 _unbindAllRecursively(c); |
408 } | 408 } |
409 } | 409 } |
410 } | 410 } |
OLD | NEW |