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

Commit 6bc6989

Browse files
author
Kamil Kisiela
committed
feat: allow to add step attribute on every field
1 parent cd113c2 commit 6bc6989

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/types/input/input.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ export default (formlyConfigProvider) => {
1515
mdMaxlength: {
1616
bound: 'md-maxlength'
1717
},
18+
// XXX angular-formly#8042d2a so we want to keep it compatible
19+
// with angular-formly releases before that commit
20+
step: {
21+
attribute: 'step'
22+
},
1823
disabled: {
1924
bound: 'ng-disabled'
2025
},
@@ -38,15 +43,4 @@ export default (formlyConfigProvider) => {
3843
};
3944
}
4045
});
41-
42-
// add only step attribute because min and max are both built-in
43-
formlyConfigProvider.extras.fieldTransform.push((fields) => {
44-
return ngModelAttrsTransformer(fields, (field) => (
45-
field.type === 'input' &&
46-
field.templateOptions &&
47-
field.templateOptions.type === 'number'
48-
), 'step', {
49-
attribute: 'step'
50-
});
51-
});
5246
};

tests/types/input-spec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,17 @@ describe('formlyMaterial - input type', () => {
118118

119119
describe('number type specific', () => {
120120
describe('step attribute', () => {
121-
it('should not be available on non number type', () => {
121+
// XXX BE instead of NOT BE because `step` attr is now fully supported
122+
// angular-formly#8042d2a
123+
it('should BE available on non number type', () => {
122124
compile({
123125
templateOptions: {
124126
type: 'text',
125127
step: 2
126128
}
127129
});
128130

129-
expect(element.attr('step')).toBeUndefined();
131+
expect(parseInt(element.attr('step'))).toBe(field.templateOptions.step);
130132
});
131133

132134
it('should be available on number type', () => {

0 commit comments

Comments
 (0)