| Index: third_party/pkg/angular/lib/core_dom/ng_mustache.dart
|
| ===================================================================
|
| --- third_party/pkg/angular/lib/core_dom/ng_mustache.dart (revision 33054)
|
| +++ third_party/pkg/angular/lib/core_dom/ng_mustache.dart (working copy)
|
| @@ -7,56 +7,30 @@
|
| String markup,
|
| Interpolate interpolate,
|
| Scope scope,
|
| - AstParser parser,
|
| - FilterMap filters) {
|
| + TextChangeListener listener) {
|
| Interpolation interpolation = interpolate(markup);
|
| - interpolation.setter = (text) => element.text = text;
|
| -
|
| - List items = interpolation.expressions.map((exp) {
|
| - return parser(exp, filters:filters);
|
| - }).toList();
|
| - AST ast = new PureFunctionAST('[[$markup]]', new ArrayFn(), items);
|
| - scope.watch(ast, interpolation.call, readOnly: true);
|
| + interpolation.setter = (text) {
|
| + element.text = text;
|
| + if (listener != null) listener.call(text);
|
| + };
|
| + interpolation.setter('');
|
| + scope.$watchSet(interpolation.watchExpressions, interpolation.call, markup.trim());
|
| }
|
|
|
| }
|
|
|
| @NgDirective(selector: r'[*=/{{.*}}/]')
|
| class NgAttrMustacheDirective {
|
| - // This Directive is special and does not go through injection.
|
| - NgAttrMustacheDirective(NodeAttrs attrs,
|
| - String markup,
|
| - Interpolate interpolate,
|
| - Scope scope,
|
| - AstParser parser,
|
| - FilterMap filters) {
|
| - var eqPos = markup.indexOf('=');
|
| - var attrName = markup.substring(0, eqPos);
|
| - var attrValue = markup.substring(eqPos + 1);
|
| - Interpolation interpolation = interpolate(attrValue);
|
| - var lastValue = markup;
|
| - interpolation.setter = (text) {
|
| - if (lastValue != text) {
|
| - lastValue = attrs[attrName] = text;
|
| - }
|
| - };
|
| - // TODO(misko): figure out how to remove call to setter. It slows down
|
| - // Block instantiation
|
| - interpolation.setter('');
|
| + static RegExp ATTR_NAME_VALUE_REGEXP = new RegExp(r'^([^=]+)=(.*)$');
|
|
|
| - List items = interpolation.expressions.map((exp) {
|
| - return parser(exp, filters:filters);
|
| - }).toList();
|
| - AST ast = new PureFunctionAST('[[$markup]]', new ArrayFn(), items);
|
| - /*
|
| - Attribute bindings are tricky. They need to be resolved on digest
|
| - inline with components so that any bindings to component can
|
| - be resolved before the component attach method. But once the
|
| - component is attached we need to run on the flush cycle rather
|
| - then digest cycle.
|
| - */
|
| - // TODO(misko): figure out how to get most of these on observe rather then watch.
|
| - scope.watch(ast, interpolation.call);
|
| +// This Directive is special and does not go through injection.
|
| + NgAttrMustacheDirective(NodeAttrs attrs, String markup, Interpolate interpolate, Scope scope) {
|
| + var match = ATTR_NAME_VALUE_REGEXP.firstMatch(markup);
|
| + var attrName = match[1];
|
| + Interpolation interpolation = interpolate(match[2]);
|
| + interpolation.setter = (text) => attrs[attrName] = text;
|
| + interpolation.setter('');
|
| + scope.$watchSet(interpolation.watchExpressions, interpolation.call, markup.trim());
|
| }
|
| }
|
|
|
|
|