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

Unified Diff: third_party/pkg/angular/lib/core/interpolate.dart

Issue 180873006: Update the Angular/DI tests to latest from github. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review feedback Created 6 years, 10 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
Index: third_party/pkg/angular/lib/core/interpolate.dart
diff --git a/third_party/pkg/angular/lib/core/interpolate.dart b/third_party/pkg/angular/lib/core/interpolate.dart
index 1d6e7bd11d3bc2b1defcf8347f2ffeea454bc829..28d09bee75654eba941bd4a4d44b4ebab811408a 100644
--- a/third_party/pkg/angular/lib/core/interpolate.dart
+++ b/third_party/pkg/angular/lib/core/interpolate.dart
@@ -1,21 +1,17 @@
part of angular.core;
-String _startSymbol = '{{';
-String _endSymbol = '}}';
-int _startSymbolLength = _startSymbol.length;
-int _endSymbolLength = _endSymbol.length;
-
class Interpolation {
final String template;
final List<String> seperators;
- final List<Getter> watchExpressions;
+ final List<String> expressions;
Function setter = (_) => _;
- Interpolation(this.template, this.seperators, this.watchExpressions);
+ Interpolation(this.template, this.seperators, this.expressions);
- String call(List parts, [_, __]) {
+ String call(List parts, [_]) {
+ if (parts == null) return seperators.join('');
var str = [];
- for(var i = 0, ii = parts.length; i < ii; i++) {
+ for (var i = 0; i < parts.length; i++) {
str.add(seperators[i]);
var value = parts[i];
str.add(value == null ? '' : '$value');
@@ -48,8 +44,13 @@ class Interpolate {
* have embedded expression in order to return an interpolation function.
* Strings with no embedded expression will return null for the
* interpolation function.
+ * - `startSymbol`: The symbol to start interpolation. '{{' by default.
+ * - `endSymbol`: The symbol to end interpolation. '}}' by default.
*/
- Interpolation call(String template, [bool mustHaveExpression = false]) {
+ Interpolation call(String template, [bool mustHaveExpression = false,
+ String startSymbol = '{{', String endSymbol = '}}']) {
+ int startSymbolLength = startSymbol.length;
+ int endSymbolLength = endSymbol.length;
int startIndex;
int endIndex;
int index = 0;
@@ -58,16 +59,15 @@ class Interpolate {
bool shouldAddSeparator = true;
String exp;
List<String> separators = [];
- List<Getter> watchExpressions = [];
+ List<String> expressions = [];
while(index < length) {
- if ( ((startIndex = template.indexOf(_startSymbol, index)) != -1) &&
- ((endIndex = template.indexOf(_endSymbol, startIndex + _startSymbolLength)) != -1) ) {
+ if ( ((startIndex = template.indexOf(startSymbol, index)) != -1) &&
+ ((endIndex = template.indexOf(endSymbol, startIndex + startSymbolLength)) != -1) ) {
separators.add(template.substring(index, startIndex));
- exp = template.substring(startIndex + _startSymbolLength, endIndex);
- Expression expression = _parse(exp);
- watchExpressions.add(expression.eval);
- index = endIndex + _endSymbolLength;
+ exp = template.substring(startIndex + startSymbolLength, endIndex);
+ expressions.add(exp);
+ index = endIndex + endSymbolLength;
hasInterpolation = true;
} else {
// we did not find anything, so we have to add the remainder to the chunks array
@@ -79,8 +79,8 @@ class Interpolate {
if (shouldAddSeparator) {
separators.add('');
}
- if (!mustHaveExpression || hasInterpolation) {
- return new Interpolation(template, separators, watchExpressions);
- }
+ return (!mustHaveExpression || hasInterpolation)
+ ? new Interpolation(template, separators, expressions)
+ : null;
}
}
« no previous file with comments | « third_party/pkg/angular/lib/core/exception_handler.dart ('k') | third_party/pkg/angular/lib/core/module.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698