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

Commit

Permalink
Merge pull request #19 from pflannery/NumberInputType
Browse files Browse the repository at this point in the history
Stores value as numeric for number input types
  • Loading branch information
John Messerly committed Feb 4, 2015
2 parents 404ecab + 1e554e6 commit 520c660
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/NodeBind.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@
var eventType = getEventForInputType(input);

function eventHandler() {
observable.setValue(input[property]);
var isNum = property == 'value' && input.type == 'number';
observable.setValue(isNum ? input.valueAsNumber : input[property]);
observable.discardChanges();
(postEventFn || noop)(input);
Platform.performMicrotaskCheckpoint();
Expand Down
16 changes: 16 additions & 0 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,22 @@ suite('Form Element Bindings', function() {
radioInputCheckedMultipleForms(shadowRoot, done);
});

test('(Number)Input.value', function(done) {
var input = testDiv.appendChild(document.createElement('input'));
testDiv.appendChild(input);
input.type = 'number';
var model = {x: 0};
bindings.push(input.bind('value', new PathObserver(model, 'x')));
input.value = "999";

then(function() {
dispatchEvent('input', input);
assert.isNumber(model.x);
assert.strictEqual(999, model.x);
done();
});
});

test('Select.selectedIndex', function(done) {
var select = testDiv.appendChild(document.createElement('select'));
testDiv.appendChild(select);
Expand Down

0 comments on commit 520c660

Please sign in to comment.