Closed Bug 1289272 Opened 8 years ago Closed 8 years ago

Consider changing the implementation of step attribute for input type=date

Categories

(Core :: DOM: Core & HTML, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla50
Tracking Status
firefox50 --- fixed

People

(Reporter: jessica, Assigned: jessica)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 2 obsolete files)

In our current implementation, in order to avoid a step mismatch, the actually step used is the LCM of 'step' and 'step scale factor'. This is kind of confusing when step is non-integer, for example, when step is 0.9 (day), the actually step used is 9 (days) [1]. Note that the step scale factor for type=date is 86400000 (which converts the days to milliseconds). What Chromium does is, for type=date, month and week, they round the step [2], so when step is 0.9 (day), the actually step used is 1 (day), and when step is 1.6, the actually step used is 2. I can't tell what Edge does, cause they seem not to set the validationMessage. The spec just says: "When the element is suffering from a step mismatch, the user agent may round the element's value to the nearest date for which the element would not suffer from a step mismatch." [3] [1] http://hg.mozilla.org/mozilla-central/file/711963e8daa3/dom/html/test/forms/test_step_attribute.html#l204 [2] https://chromium.googlesource.com/chromium/blink/+/master/Source/core/html/forms/StepRange.cpp#126 [3] https://html.spec.whatwg.org/multipage/forms.html#date-state-(type=date)
Attached patch patch, v1. (obsolete) (deleted) — Splinter Review
Assignee: nobody → jjong
Comment on attachment 8774622 [details] [diff] [review] patch, v1. Review of attachment 8774622 [details] [diff] [review]: ----------------------------------------------------------------- Just round the value of step attribute for type=date.
Attachment #8774622 - Flags: review?(bugs)
Priority: -- → P2
Comment on attachment 8774622 [details] [diff] [review] patch, v1. Doesn't this break inputelement.step getter? https://html.spec.whatwg.org/multipage/forms.html#the-step-attribute With step 0.9, blink keeps returning 0.9.
Attachment #8774622 - Flags: review?(bugs) → review-
(In reply to Olli Pettay [:smaug] from comment #3) > Comment on attachment 8774622 [details] [diff] [review] > patch, v1. > > Doesn't this break inputelement.step getter? > https://html.spec.whatwg.org/multipage/forms.html#the-step-attribute No, it doesn't. The GetStep() here is used internally for computations, the step attribute getter uses the NS_IMPL_STRING_ATTR macro [1]. I'll add a test to verify this. > > With step 0.9, blink keeps returning 0.9. [1] http://hg.mozilla.org/mozilla-central/file/462dc6b44adb/dom/html/HTMLInputElement.cpp#l1592
Attached patch patch, v2. (obsolete) (deleted) — Splinter Review
Added tests to check step attribute value is unchanged
Attachment #8774622 - Attachment is obsolete: true
Attachment #8774991 - Flags: review?(bugs)
Comment on attachment 8774991 [details] [diff] [review] patch, v2. I see, thanks.
Attachment #8774991 - Flags: review?(bugs) → review+
Attached patch patch, v3. (deleted) — Splinter Review
Update form-validation-reportValidity.html expectation data: tests don't timeout now since we no longer use EuclidLCM functions.
Attachment #8774991 - Attachment is obsolete: true
Attachment #8775503 - Flags: review+
Pushed by ryanvm@gmail.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/91eaa3e92b41 Simplify the computation of step values for input type=date. r=smaug
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: