Skip to content

Commit

Permalink
Merge pull request #15676 from Serabe/fix/15675
Browse files Browse the repository at this point in the history
[BUGFIX beta] Fix range input values
  • Loading branch information
rwjblue authored Sep 21, 2017
2 parents dc7bf1a + 9656b43 commit d31f0d1
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ember-glimmer/lib/components/text_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ export default Component.extend(TextSupport, {
'inputmode',
'lang',
'list',
'type', // needs to be before min and max. See #15675
'max',
'min',
'multiple',
'name',
'pattern',
'size',
'step',
'type',
'value',
'width'
],
Expand Down
53 changes: 53 additions & 0 deletions packages/ember-glimmer/tests/integration/helpers/input-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,3 +653,56 @@ moduleFor(`Helpers test: {{input type='text'}}`, class extends InputRenderingTes
this.assertAttr('tabindex', undefined);
}
});

// These are the permutations of the set:
// ['type="range"', 'min="-5" max="50"', 'value="%x"']
[
'type="range" min="-5" max="50" value="%x"',
'type="range" value="%x" min="-5" max="50"',
'min="-5" max="50" type="range" value="%x"',
'min="-5" max="50" value="%x" type="range"',
'value="%x" min="-5" max="50" type="range"',
'value="%x" type="range" min="-5" max="50"',
].forEach(attrs => {
moduleFor(`[GH#15675] Helpers test: {{input ${attrs}}}`, class extends InputRenderingTest {
renderInput(value = 25) {
this.render(`{{input ${ attrs.replace("%x", value) }}}`);
}

assertValue(expected) {
let type = this.$input().attr('type');

if (type !== 'range') {
this.assert.ok(true, 'IE9 does not support range items');
return;
}

super.assertValue(expected);
}

['@test value over default max but below set max is kept'](assert) {
this.renderInput("25");
this.assertValue("25");
}

['@test value below default min but above set min is kept'](assert) {
this.renderInput("-2");
this.assertValue("-2");
}

['@test in the valid default range is kept'](assert) {
this.renderInput("5");
this.assertValue("5");
}

['@test value above max is reset to max'](assert) {
this.renderInput("55");
this.assertValue("50");
}

['@test value below min is reset to min'](assert) {
this.renderInput("-10");
this.assertValue("-5");
}
});
});

0 comments on commit d31f0d1

Please sign in to comment.