Skip to content

Commit

Permalink
Don't create private setter for computed properties. Fixes #2016.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Jul 9, 2015
1 parent c263ad5 commit b98b847
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/lib/bind/accessors.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,13 @@
// 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 && 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;
}
Expand Down
6 changes: 4 additions & 2 deletions test/unit/bind-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -172,7 +174,7 @@
notifierWithoutComputingChanged: function() {
this.observerCounts.notifierWithoutComputingChanged++;
},
computeNotifyingValue: function(val) {
_setComputednotifyingvalue: function(val) {
return val + 2;
},
computeFromMultipleValues: function(sum1, sum2, divide) {
Expand Down

0 comments on commit b98b847

Please sign in to comment.