Support inputs of type number
Showing
2 changed files
with
19 additions
and
1 deletions
... | @@ -99,6 +99,24 @@ describe('Rivets.Binding', function() { | ... | @@ -99,6 +99,24 @@ describe('Rivets.Binding', function() { |
99 | }); | 99 | }); |
100 | }); | 100 | }); |
101 | }); | 101 | }); |
102 | |||
103 | describe('publish()', function() { | ||
104 | it("should publish the value of a number input", function() { | ||
105 | numberInput = document.createElement('input'); | ||
106 | numberInput.setAttribute('type', 'number'); | ||
107 | numberInput.setAttribute('data-value', 'obj.num'); | ||
108 | |||
109 | view = rivets.bind(numberInput, {obj: {num: 42}}); | ||
110 | binding = view.bindings[0]; | ||
111 | model = binding.model; | ||
112 | |||
113 | numberInput.value = 42; | ||
114 | |||
115 | spyOn(rivets.config.adapter, 'publish'); | ||
116 | binding.publish({target: numberInput}); | ||
117 | expect(rivets.config.adapter.publish).toHaveBeenCalledWith(model, 'num', '42'); | ||
118 | }); | ||
119 | }); | ||
102 | 120 | ||
103 | describe('formattedValue()', function() { | 121 | describe('formattedValue()', function() { |
104 | it('applies the current formatters on the supplied value', function() { | 122 | it('applies the current formatters on the supplied value', function() { | ... | ... |
... | @@ -148,7 +148,7 @@ unbindEvent = (el, event, fn) -> | ... | @@ -148,7 +148,7 @@ unbindEvent = (el, event, fn) -> |
148 | # Returns the current input value for the specified element. | 148 | # Returns the current input value for the specified element. |
149 | getInputValue = (el) -> | 149 | getInputValue = (el) -> |
150 | switch el.type | 150 | switch el.type |
151 | when 'text', 'textarea', 'password', 'select-one', 'radio' then el.value | 151 | when 'text', 'textarea', 'password', 'select-one', 'radio', 'number' then el.value |
152 | when 'checkbox' then el.checked | 152 | when 'checkbox' then el.checked |
153 | 153 | ||
154 | # Returns an event binding routine for the specified event. | 154 | # Returns an event binding routine for the specified event. | ... | ... |
-
Please register or sign in to post a comment