Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit 5a161b1

Browse files
committed
Stores value as numeric for number input types
added numeric test
1 parent 404ecab commit 5a161b1

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/NodeBind.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,11 @@
173173
var eventType = getEventForInputType(input);
174174

175175
function eventHandler() {
176-
observable.setValue(input[property]);
176+
if (property == 'value' && input.type == 'number' )
177+
observable.setValue(input.valueAsNumber);
178+
else
179+
observable.setValue(input[property]);
180+
177181
observable.discardChanges();
178182
(postEventFn || noop)(input);
179183
Platform.performMicrotaskCheckpoint();

tests/tests.js

+16
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,22 @@ suite('Form Element Bindings', function() {
652652
radioInputCheckedMultipleForms(shadowRoot, done);
653653
});
654654

655+
test('(Number)Input.number', function(done) {
656+
var input = testDiv.appendChild(document.createElement('input'));
657+
testDiv.appendChild(input);
658+
input.type = 'number';
659+
var model = {x: 0};
660+
bindings.push(input.bind('value', new PathObserver(model, 'x')));
661+
input.value = "999";
662+
663+
then(function() {
664+
dispatchEvent('input', input);
665+
assert.isNumber(model.x);
666+
assert.strictEqual(999, model.x);
667+
done();
668+
});
669+
});
670+
655671
test('Select.selectedIndex', function(done) {
656672
var select = testDiv.appendChild(document.createElement('select'));
657673
testDiv.appendChild(select);

0 commit comments

Comments
 (0)