751de7b5 by Paul Jones

Support inputs of type number

1 parent 962107e9
......@@ -100,6 +100,24 @@ describe('Rivets.Binding', function() {
});
});
describe('publish()', function() {
it("should publish the value of a number input", function() {
numberInput = document.createElement('input');
numberInput.setAttribute('type', 'number');
numberInput.setAttribute('data-value', 'obj.num');
view = rivets.bind(numberInput, {obj: {num: 42}});
binding = view.bindings[0];
model = binding.model;
numberInput.value = 42;
spyOn(rivets.config.adapter, 'publish');
binding.publish({target: numberInput});
expect(rivets.config.adapter.publish).toHaveBeenCalledWith(model, 'num', '42');
});
});
describe('formattedValue()', function() {
it('applies the current formatters on the supplied value', function() {
rivets.config.formatters = {
......
......@@ -148,7 +148,7 @@ unbindEvent = (el, event, fn) ->
# Returns the current input value for the specified element.
getInputValue = (el) ->
switch el.type
when 'text', 'textarea', 'password', 'select-one', 'radio' then el.value
when 'text', 'textarea', 'password', 'select-one', 'radio', 'number' then el.value
when 'checkbox' then el.checked
# Returns an event binding routine for the specified event.
......