Skip to content

Commit

Permalink
Simplified removing custom effects.
Browse files Browse the repository at this point in the history
Simply call `this.removeCustomEffect(fx)`. We store the trigger in the
effect type.
  • Loading branch information
kaste committed Mar 30, 2016
1 parent 071f1aa commit d10636c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/lib/bind/accessors.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@
var propEffect = {
kind: kind,
effect: effect,
fn: Polymer.Bind['_' + kind + 'Effect']
fn: Polymer.Bind['_' + kind + 'Effect'],
trigger: property
};
fx.push(propEffect);
return propEffect;
Expand Down
6 changes: 4 additions & 2 deletions src/standard/effectBuilder.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@
return this._addPropertyEffect(property, 'function', fn);
},

removeCustomEffect: function(property, fx) {
var effects = this._propertyEffects && this._propertyEffects[property];
removeCustomEffect: function(fx) {
var property = fx.trigger;
var effects = property && this._propertyEffects &&
this._propertyEffects[property];
if (effects) {
var index = effects.indexOf(fx);
if (index !== -1) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@
called += 1;
});

el.removeCustomEffect('foo', fx);
el.removeCustomEffect(fx);

el.foo = 'bar';
assert.equal(called, 0);
Expand Down

0 comments on commit d10636c

Please sign in to comment.