Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX beta] Fix range input values #15676

Merged
merged 1 commit into from
Sep 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
}
});
});