:in-range & :out-of-range CSS pseudo-classes shouldn't match disabled or readonly inputs

RESOLVED FIXED in Firefox 50

Status

()

Core
CSS Parsing and Computation
RESOLVED FIXED
a year ago
a year ago

People

(Reporter: Chris Rebert, Assigned: Thomas Wisniewski)

Tracking

(Blocks: 1 bug, {dev-doc-complete, html5, testcase})

Trunk
mozilla50
dev-doc-complete, html5, testcase
Points:
---

Firefox Tracking Flags

(firefox48 affected, firefox50 fixed)

Details

(Whiteboard: [parity-chrome][parity-webkit][parity-safari], URL)

Attachments

(2 attachments)

(Reporter)

Description

a year ago
Created attachment 8740753 [details]
Testcase demonstrating the bug

Steps to reproduce:
1. Open the attached testcase webpage in Firefox.
2. Observe the colors of the outlines of the <input>s.

What is the expected behavior?
The outlines should be green, indicating that the disabled or readonly <input type=number>s did not match the :in-range or :out-of-range CSS pseudo-classes.

What went wrong?
The outlines are orange and red, indicating that the disabled or readonly <input type=number>s matched the :in-range or :out-of-range CSS pseudo-classes.

----

Based on my reading of the HTML spec, :in-range and :out-of-range should never apply to disabled or readonly <input>s.

Per https://html.spec.whatwg.org/multipage/scripting.html#selector-in-range
> The :in-range pseudo-class must match all elements that are **candidates for constraint validation**, have range limitations, and [...]
> The :out-of-range pseudo-class must match all elements that are **candidates for constraint validation**, have range limitations, and  [...]

Per https://html.spec.whatwg.org/multipage/forms.html#candidate-for-constraint-validation
> A submittable element is a **candidate for constraint validation** except when a condition has **barred the element from constraint validation**.

Per https://html.spec.whatwg.org/multipage/forms.html#the-readonly-attribute:barred-from-constraint-validation
> If the **readonly** attribute is specified on an input element, the element is **barred from constraint validation**.

Per https://html.spec.whatwg.org/multipage/forms.html#enabling-and-disabling-form-controls:-the-disabled-attribute:barred-from-constraint-validation
> If an element is **disabled**, it is **barred from constraint validation**.

Thus, disabled and readonly <input>s are barred from constraint validation, meaning they are not candidates for constraint validation, thus causing them to be disqualified by the 1st of the 3 conditions which are required for an element to match :in-range or :out-of-range.
(Reporter)

Updated

a year ago
(Reporter)

Updated

a year ago
(Reporter)

Updated

a year ago
Keywords: html5
(Reporter)

Updated

a year ago
Blocks: 693083
(Reporter)

Updated

a year ago
(Reporter)

Updated

a year ago
Whiteboard: [parity-chrome]
(Reporter)

Updated

a year ago
(Reporter)

Comment 1

a year ago
This has now been fixed in both WebKit and Chrome.
See the respective bug links in the "See Also" field.
Whiteboard: [parity-chrome] → [parity-chrome][parity-webkit][parity-safari]
(Assignee)

Comment 2

a year ago
Created attachment 8769503 [details] [diff] [review]
1264157-do_not_match_disabled_or_readonly_inputs_with_in-range_or_out-of-range.diff

Here's a patch with a successful try-run: https://treeherder.mozilla.org/#/jobs?repo=try&revision=051bc37b198a&selectedJob=23605802

Note that until the time, week, and datetimelocal elements also correctly support range constraints, the web platform test will continue to fail. As such I added a mochitest in the patch just for this bug, which can be removed when the time comes.
Assignee: nobody → wisniewskit
Status: NEW → ASSIGNED
Attachment #8769503 - Flags: review?(bzbarsky)
Comment on attachment 8769503 [details] [diff] [review]
1264157-do_not_match_disabled_or_readonly_inputs_with_in-range_or_out-of-range.diff

r=me

Can you check this in yourself, or do you need someone to check it in for you?
Flags: needinfo?(wisniewskit)
Attachment #8769503 - Flags: review?(bzbarsky) → review+
(Assignee)

Comment 4

a year ago
No, I can set checkin-needed, but I don't have actual commit privileges yet.
Flags: needinfo?(wisniewskit)
OK.  Let's set that, and if the sheriffs haven't gotten to this by tomorrow I'll get it landed.

Thank you for the patch!
Keywords: checkin-needed

Comment 6

a year ago
Pushed by cbook@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/cee7b4d83f04
Do not match disabled/readonly inputs with :in-range and :out-of-range. r=bz
Keywords: checkin-needed

Comment 7

a year ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/cee7b4d83f04
Status: ASSIGNED → RESOLVED
Last Resolved: a year ago
status-firefox50: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
I've added a compatibility note for this to https://developer.mozilla.org/en-US/docs/Web/CSS/:in-range#Browser_compatibility.

Sebastian
Keywords: dev-doc-complete
I think this is worth a mention in Firefox 50 for devs too.
Keywords: dev-doc-complete → dev-doc-needed
(In reply to Jean-Yves Perrier [:teoli] from comment #9)
> I think this is worth a mention in Firefox 50 for devs too.

Added.

Sebastian
Keywords: dev-doc-needed → dev-doc-complete
You need to log in before you can comment on or make changes to this bug.