Don't create private setter for computed properties. Fixes #2016.

This commit is contained in:
Kevin Schaaf
2015-07-09 10:16:47 -07:00
parent c263ad5906
commit 980f22e6a8
2 changed files with 11 additions and 4 deletions

View File

@@ -169,8 +169,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
// ReadOnly properties have a private setter only
// TODO(kschaaf): Per current Bind factoring, we shouldn't
// be interrogating the prototype here
if (model.getPropertyInfo && model.getPropertyInfo(property).readOnly) {
model['_set' + this.upper(property)] = setter;
var info = model.getPropertyInfo && model.getPropertyInfo(property);
if (info.readOnly) {
// Computed properties are read-only (no property setter), but also don't
// need a private setter since they should not be called by the user
if (!info.computed) {
model['_set' + this.upper(property)] = setter;
}
} else {
defun.set = setter;
}

View File

@@ -58,7 +58,9 @@
computednotifyingvalue: {
type: Number,
notify: true,
computed: 'computeNotifyingValue(notifyingvalue)'
// Naming here is to test that a private setter is not created for
// computed properties
computed: '_setComputednotifyingvalue(notifyingvalue)'
},
computedFromMultipleValues: {
type: Number,
@@ -172,7 +174,7 @@
notifierWithoutComputingChanged: function() {
this.observerCounts.notifierWithoutComputingChanged++;
},
computeNotifyingValue: function(val) {
_setComputednotifyingvalue: function(val) {
return val + 2;
},
computeFromMultipleValues: function(sum1, sum2, divide) {