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

Commit

Permalink
Stores value as numeric for number input types
Browse files Browse the repository at this point in the history
added numeric test
  • Loading branch information
pflannery committed Feb 3, 2015
1 parent 404ecab commit 5a161b1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/NodeBind.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@
var eventType = getEventForInputType(input);

function eventHandler() {
observable.setValue(input[property]);
if (property == 'value' && input.type == 'number' )
observable.setValue(input.valueAsNumber);
else
observable.setValue(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.number', 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 5a161b1

Please sign in to comment.