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

Range Elements Report Wrong Initial Value #14958

Closed
jherdman opened this issue Feb 24, 2017 · 7 comments · Fixed by glimmerjs/glimmer-vm#726
Closed

Range Elements Report Wrong Initial Value #14958

jherdman opened this issue Feb 24, 2017 · 7 comments · Fixed by glimmerjs/glimmer-vm#726

Comments

@jherdman
Copy link
Contributor

Range inputs report the wrong initial value for both the native <input and helper/component-based {{input since Ember 2.10.

Here's a demo Twiddle of the problem:

https://ember-twiddle.com/61645ec16fca7f5ff5a65c2b407ce94c?openFiles=components.range-element-spy.js%2Ctemplates.components.range-element-spy.hbs

And a JS Bin showing the expected behaviour:

http://output.jsbin.com/dodayozima

I'll see about writing up a failing test soon.

@locks
Copy link
Contributor

locks commented Feb 25, 2017

Reproduction with DOM API: http://jsbin.com/luxuyi/edit?html,js,console,output

@jherdman
Copy link
Contributor Author

OK, so using the example from @locks I can see that this happens in Chrome, and Firefox, but not Safari. I suppose I should be reporting this bug upstream to the various OEMs. Does anyone have guidance on this?

@Serabe
Copy link
Member

Serabe commented Mar 8, 2017

Firefox and Chrome are doing it right following the spec.

In the absence of values for min, max and value, they get the values 0, 100 and (max+min)/2.

Closing this as a non issue.

Thank you!

@Serabe Serabe closed this as completed Mar 8, 2017
@Serabe
Copy link
Member

Serabe commented Mar 8, 2017

Reopening for further consideration.

Thank you!

@Serabe Serabe reopened this Mar 8, 2017
@rwjblue
Copy link
Member

rwjblue commented Mar 9, 2017

@wycats / @chancancode created an issue over on the spec repo for this. Follow along at whatwg/html#2427.

@chancancode
Copy link
Member

chancancode commented Mar 9, 2017 via email

Serabe added a commit to Serabe/glimmer-vm that referenced this issue Mar 15, 2017
If a template had an `input` `range` whose type was set before a max or a min
attribute was added, the initial value would be wrong.

In plain HTML, the initial value for `<input max="10" type="range" />` would be
`5` (`(min + max) / 2 = (0 + 10) / 2 = 5`).

In Glimmer, this would be 10 because the code would be equivalent to:

```js
let input = document.createElement('input');
input.type = "range";
input.max = "10";
```

Setting `type` to `range` would make the value sanitization algorihtm to kick
in, setting the value to 50. When setting the `max` to `10`, the algorithm
would sanitize the value (50 by now) to the maximum (10).

More info in whatwg/html#2427
Fixes emberjs/ember.js#14958
@pixelhandler
Copy link
Contributor

pixelhandler commented Mar 17, 2017

Could this be a work around, https://github.com/trek/ember-input-range ?

Serabe added a commit to Serabe/glimmer-vm that referenced this issue Oct 27, 2017
If a template had an `input` `range` whose type was set before a max or a min
attribute was added, the initial value would be wrong.

In plain HTML, the initial value for `<input max="10" type="range" />` would be
`5` (`(min + max) / 2 = (0 + 10) / 2 = 5`).

In Glimmer, this would be 10 because the code would be equivalent to:

```js
let input = document.createElement('input');
input.type = "range";
input.max = "10";
```

Setting `type` to `range` would make the value sanitization algorihtm to kick
in, setting the value to 50. When setting the `max` to `10`, the algorithm
would sanitize the value (50 by now) to the maximum (10).

This was originally discussed in glimmerjs#425, but an alternative solution was
asked for. While this PR keeps part of the original implementation
(could not find a simple way to fix the issue when a template is being
rendered), this PR goes further and fixes it for Emberish components and
`...attributes` in Glimmer components.

More info in whatwg/html#2427
Fixes emberjs/ember.js#14958
Serabe added a commit to Serabe/glimmer-vm that referenced this issue Nov 17, 2017
If a template had an `input` `range` whose type was set before a max or a min
attribute was added, the initial value would be wrong.

In plain HTML, the initial value for `<input max="10" type="range" />` would be
`5` (`(min + max) / 2 = (0 + 10) / 2 = 5`).

In Glimmer, this would be 10 because the code would be equivalent to:

```js
let input = document.createElement('input');
input.type = "range";
input.max = "10";
```

Setting `type` to `range` would make the value sanitization algorihtm to kick
in, setting the value to 50. When setting the `max` to `10`, the algorithm
would sanitize the value (50 by now) to the maximum (10).

This was originally discussed in glimmerjs#425, but an alternative solution was
asked for. While this PR keeps part of the original implementation
(could not find a simple way to fix the issue when a template is being
rendered), this PR goes further and fixes it for Emberish components and
`...attributes` in Glimmer components.

More info in whatwg/html#2427
Fixes emberjs/ember.js#14958
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants