-
Notifications
You must be signed in to change notification settings - Fork 544
stepUp/Down algorithm does not match reality #281
Comments
step=2.6 scalar=2 => 6 month step --> https://jsfiddle.net/a3cafwv0/7/ So, Edge/Chrome both apply the ceil(step) then multiply by scalar for step up/down (to get 6 months either way). |
That last comment was not quite true, they do round the step value. Regardless, I believe I've now captured the logic in a PR. Please review. |
For those reviewing: The essence of the problem is that for both: My change adjusts the value ultimately used as the step value (before it is multiplied by the scalar value) so that for month, date, time, etc., the step snapping is done using whole integers which prevents it from landing on a fractional scale unit. This appears to match exactly what browsers are doing. |
Ran this by some internal folks at Microsoft who implemented Edge's new input controls (Scott & Co.) [info removed for privacy]:
|
In my reading of http://w3c.github.io/html/sec-forms.html#dom-htmlinputelement-stepup
with the following input:
The algorithm seems to get all the way through to step 11, where it tries to convert value (3.5) to a month string. I think somewhere along the line it must be triggering the "suffering from a step-mismatch" because 3.5 does not convert to a legitimate month value, so rounding occurs.
I think step 7 is trying to do this, but as worded, the step base-minus-value (-2) is an integral multiple of the allowed value step (0.5) [using a integral multiple of -4].
The algorithm should probably do an explicit rounding, perhaps via a step 10 1/2 that does a
ceil(value)
if value suffers a step-mismatch andstepUp()
was called,floor(value)
in thestepdown()
case. (Since small steps still result in an increment, e.g., step values of "0.2").Test: https://jsfiddle.net/a3cafwv0/
Edge/Chrome: round-up to the next month.
Firefox/Safari: do not support type="month"
The text was updated successfully, but these errors were encountered: