fb1984a9 by Michael Richards

Merge branch 'model-as-context-on-function-calls'

2 parents 44468934 1594f8c0
......@@ -85,6 +85,13 @@ describe('Rivets.Binding', function() {
expect(binding.routine).toHaveBeenCalledWith(el, 'awesome sweater');
});
it('calls methods with the object as context', function() {
binding.model = {foo: 'bar'};
spyOn(binding, 'routine');
binding.set(function() { return this.foo; });
expect(binding.routine).toHaveBeenCalledWith(el, binding.model.foo);
});
describe('on an event binding', function() {
beforeEach(function() {
binding.options.special = 'event';
......
......@@ -48,7 +48,7 @@ class Rivets.Binding
@routine @el, value, @currentListener
@currentListener = value
else
value = value() if value instanceof Function
value = value.call(@model) if value instanceof Function
@routine @el, value
# Subscribes to the model for changes at the specified keypath. Bi-directional
......