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() {
rivets.routines.value(input, 'pitchfork');
expect(input.value).toBe('pitchfork');
});
it("applies a default value to the element when the model doesn't contain it", function() {
rivets.routines.value(input, undefined);
expect(input.value).toBe('');
});
});
describe('show', function() {
......
......@@ -174,7 +174,7 @@ Rivets.routines =
html: (el, value) ->
el.innerHTML = value or ''
value: (el, value) ->
el.value = value
el.value = value or ''
text: (el, value) ->
if el.innerText?
el.innerText = value or ''
......