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

Side by Side Diff: dart/pkg/polymer_expressions/lib/polymer_expressions.dart

Issue 56933002: Version 0.8.10.1 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month 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
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 /** 5 /**
6 * A binding delegate used with Polymer elements that 6 * A binding delegate used with Polymer elements that
7 * allows for complex binding expressions, including 7 * allows for complex binding expressions, including
8 * property access, function invocation, 8 * property access, function invocation,
9 * list/map indexing, and two-way filtering. 9 * list/map indexing, and two-way filtering.
10 * 10 *
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 * variables used as [globals]. If no globals are supplied, a copy of the 63 * variables used as [globals]. If no globals are supplied, a copy of the
64 * [DEFAULT_GLOBALS] will be used. 64 * [DEFAULT_GLOBALS] will be used.
65 */ 65 */
66 PolymerExpressions({Map<String, Object> globals}) 66 PolymerExpressions({Map<String, Object> globals})
67 : globals = (globals == null) ? 67 : globals = (globals == null) ?
68 new Map<String, Object>.from(DEFAULT_GLOBALS) : globals; 68 new Map<String, Object>.from(DEFAULT_GLOBALS) : globals;
69 69
70 prepareBinding(String path, name, node) { 70 prepareBinding(String path, name, node) {
71 if (path == null) return null; 71 if (path == null) return null;
72 var expr = new Parser(path).parse(); 72 var expr = new Parser(path).parse();
73
74 // For template bind/repeat to an empty path, just pass through the model.
75 // We don't want to unwrap the Scope.
76 // TODO(jmesserly): a custom element extending <template> could notice this
77 // behavior. An alternative is to associate the Scope with the node via an
78 // Expando, which is what the JavaScript PolymerExpressions does.
79 if (isSemanticTemplate(node) && (name == 'bind' || name == 'repeat') &&
80 expr is EmptyExpression) {
81 return null;
82 }
83
73 return (model, node) { 84 return (model, node) {
74 if (model is! Scope) { 85 if (model is! Scope) {
75 model = new Scope(model: model, variables: globals); 86 model = new Scope(model: model, variables: globals);
76 } 87 }
77 if (node is Element && name == "class") { 88 if (node is Element && name == "class") {
78 return new _Binding(expr, model, _classAttributeConverter); 89 return new _Binding(expr, model, _classAttributeConverter);
79 } 90 }
80 if (node is Element && name == "style") { 91 if (node is Element && name == "style") {
81 return new _Binding(expr, model, _styleAttributeConverter); 92 return new _Binding(expr, model, _styleAttributeConverter);
82 } 93 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 @reflectable get value => _value; 139 @reflectable get value => _value;
129 140
130 @reflectable set value(v) { 141 @reflectable set value(v) {
131 try { 142 try {
132 assign(_expr, v, _scope); 143 assign(_expr, v, _scope);
133 } on EvalException catch (e) { 144 } on EvalException catch (e) {
134 _logger.warning("Error evaluating expression '$_expr': ${e.message}"); 145 _logger.warning("Error evaluating expression '$_expr': ${e.message}");
135 } 146 }
136 } 147 }
137 } 148 }
OLDNEW
« no previous file with comments | « dart/pkg/polymer/test/nested_binding_test.html ('k') | dart/pkg/shadow_dom/lib/shadow_dom.debug.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698