fb1984a9 by Michael Richards

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

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