Skip to content

Commit e7d6106

Browse files
committed
fix(input): Render 0 (number) as 0 (not empty string)
1 parent c4c60c2 commit e7d6106

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/widget/input.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ function textInputType(scope, element, attr, ctrl) {
382382
});
383383

384384
ctrl.render = function() {
385-
element.val(ctrl.viewValue || '');
385+
element.val(isEmpty(ctrl.viewValue) ? '' : ctrl.viewValue);
386386
};
387387

388388
// pattern validator

test/widget/inputSpec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,16 @@ describe('input', function() {
334334
});
335335

336336

337+
it('should render 0 even if it is a number', function() {
338+
compileInput('<input type="text" ng:model="value" />');
339+
scope.$apply(function() {
340+
scope.value = 0;
341+
});
342+
343+
expect(inputElm.val()).toBe('0');
344+
});
345+
346+
337347
describe('pattern', function() {
338348

339349
it('should validate in-lined pattern', function() {

0 commit comments

Comments
 (0)