237f7d9b by Michael Richards

Merge pull request #37 from paulj/default-value-bindings

Default to an empty string for undefined value bindings
2 parents 35e7049b cb840c20
...@@ -37,6 +37,11 @@ describe('Routines', function() { ...@@ -37,6 +37,11 @@ describe('Routines', function() {
37 rivets.routines.value(input, 'pitchfork'); 37 rivets.routines.value(input, 'pitchfork');
38 expect(input.value).toBe('pitchfork'); 38 expect(input.value).toBe('pitchfork');
39 }); 39 });
40
41 it("applies a default value to the element when the model doesn't contain it", function() {
42 rivets.routines.value(input, undefined);
43 expect(input.value).toBe('');
44 });
40 }); 45 });
41 46
42 describe('show', function() { 47 describe('show', function() {
......
...@@ -174,7 +174,7 @@ Rivets.routines = ...@@ -174,7 +174,7 @@ Rivets.routines =
174 html: (el, value) -> 174 html: (el, value) ->
175 el.innerHTML = value or '' 175 el.innerHTML = value or ''
176 value: (el, value) -> 176 value: (el, value) ->
177 el.value = value 177 el.value = value or ''
178 text: (el, value) -> 178 text: (el, value) ->
179 if el.innerText? 179 if el.innerText?
180 el.innerText = value or '' 180 el.innerText = value or ''
......