Correctly generate code when using transformers in polymer-expressions.

R=jmesserly@google.com

Review URL: https://codereview.chromium.org//226393003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34743 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
sigmund@google.com 2014-04-04 20:27:36 +00:00
parent dfef6d6726
commit 5cda9425d8
3 changed files with 12 additions and 3 deletions

View file

@ -529,8 +529,11 @@ class _SubExpressionVisitor extends pe.RecursiveVisitor {
void preVisitExpression(e) {
// For two-way bindings the outermost expression may be updated, so we need
// both the getter and the setter, but subexpressions only need the getter.
// So we exclude setters as soon as we go deeper in the tree.
// both the getter and the setter, but we only need the getter for
// subexpressions. We exclude setters as soon as we go deeper in the tree,
// except when we see a filter (that can potentially be a two-way
// transformer).
if (e is pe.BinaryOperator && e.operator == '|') return;
_includeSetter = false;
}

View file

@ -1,5 +1,5 @@
name: polymer
version: 0.10.0-pre.6
version: 0.10.0-pre.7.dev
author: Polymer.dart Authors <web-ui-dev@dartlang.org>
description: >
Polymer.dart is a new type of library for the web, built on top of Web

View file

@ -305,6 +305,7 @@ codegenTests(phases) {
'<div data-attribute="{{anotherAttribute}}"></div>'
// input and custom-element attributes are treated as 2-way bindings:
'<input value="{{this.is.twoWay}}">'
'<input value="{{this.is.twoWayInt | intToStringTransformer}}">'
'<something-else my-attribute="{{here.too}}"></something-else>'
'<div on-click="{{methodName}}"></div>'
'<div on-click="{{@read.method}}"></div>'
@ -331,6 +332,7 @@ codegenTests(phases) {
#anotherNode: (o) => o.anotherNode,
#attribute: (o) => o.attribute,
#here: (o) => o.here,
#intToStringTransformer: (o) => o.intToStringTransformer,
#is: (o) => o.is,
#method: (o) => o.method,
#methodName: (o) => o.methodName,
@ -338,11 +340,13 @@ codegenTests(phases) {
#read: (o) => o.read,
#too: (o) => o.too,
#twoWay: (o) => o.twoWay,
#twoWayInt: (o) => o.twoWayInt,
#within: (o) => o.within,
},
setters: {
#too: (o, v) { o.too = v; },
#twoWay: (o, v) { o.twoWay = v; },
#twoWayInt: (o, v) { o.twoWayInt = v; },
},
names: {
#a: r'a',
@ -351,6 +355,7 @@ codegenTests(phases) {
#anotherNode: r'anotherNode',
#attribute: r'attribute',
#here: r'here',
#intToStringTransformer: r'intToStringTransformer',
#is: r'is',
#method: r'method',
#methodName: r'methodName',
@ -358,6 +363,7 @@ codegenTests(phases) {
#read: r'read',
#too: r'too',
#twoWay: r'twoWay',
#twoWayInt: r'twoWayInt',
#within: r'within',
}));
configureForDeployment([