diff --git a/src/lib/bind/accessors.html b/src/lib/bind/accessors.html index 7a9f96ed..b1dae044 100644 --- a/src/lib/bind/accessors.html +++ b/src/lib/bind/accessors.html @@ -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; } diff --git a/test/unit/bind-elements.html b/test/unit/bind-elements.html index db05b7a5..85103597 100644 --- a/test/unit/bind-elements.html +++ b/test/unit/bind-elements.html @@ -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) {