This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 12151 - :in-range and :out-of-range should only apply to input elements with a type for which min or max apply
Summary: :in-range and :out-of-range should only apply to input elements with a type f...
Status: RESOLVED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: LC1 HTML5 spec (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-22 00:08 UTC by Mounir Lamouri
Modified: 2011-08-04 05:17 UTC (History)
7 users (show)

See Also:


Attachments

Description Mounir Lamouri 2011-02-22 00:08:17 UTC
According to CSS3-UI [1], "The :in-range and :out-of-range pseudo-classes apply only to elements that have range limitations." but according to HTML specs [2], :in-range and :out-of-range apply to all elements that are candidates for constraint validation (then one will apply or the other).

It seems better to have those pseudo-classes only apply to input elements with a type for which min or max apply (number, range and all date/time types).

[1] http://www.w3.org/TR/css3-ui/#pseudo-range
[2] http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#pseudo-classes
Comment 1 Jonas Sicking (Not reading bugmail) 2011-02-22 00:27:14 UTC
So you're saying that it should apply to all of:

<input type=number max="4711">
<input type=number min="4711">
<input type=number min="17" max="4711">

but not apply to any of:

<input type=number>
<input type=text max="14">
<input type=date>
<input type=time>

?
Comment 2 Mounir Lamouri 2011-02-22 00:34:13 UTC
(In reply to comment #1)
> So you're saying that it should apply to all of:
> 
> <input type=number max="4711">
> <input type=number min="4711">
> <input type=number min="17" max="4711">

Yes.

> but not apply to any of:
> 
> <input type=number>
> <input type=text max="14">
> <input type=date>
> <input type=time>

I agree for <input type='text' max='14'> for the others, those types can be limited (min and max apply to them). My original comment ask to have the pseudo-classes always applying to number, range and date/times types (even if min and max isn't present). I wouldn't disagree to have them apply only if min or max is present but in that case, what should we do if min or max isn't valid? (<input type='number' max="foo"> for example).
I think it's easier to understand and implement to have these pseudo-classes applying to some types instead of applying for some types if a specific attribute is present and valid.
Comment 3 Jonas Sicking (Not reading bugmail) 2011-02-22 05:47:40 UTC
To me it seems most consistent to have them apply only if there in fact is a range.

While it's more common to talk about ranges of numbers, in database contexts it's quite common to talk about ranges of strings. For example you can request all records between "a" and "c" which would include "aa" and "azzz", but not "d".

So I think it's most consistent if the classes apply only if an actual range limitation is imposed on the submitted value. Which would mean for:

<input type=number max=4711>
<input type=date min="1987-06-06">

but not for any of

<input type=number>
<input type=number max="foo">
<input type=date min="yesterday-ish">
Comment 4 Mounir Lamouri 2011-02-22 23:07:35 UTC
I would be fine with that too but I'm wondering how is that more consistent? I mean, is there anything similar in HTML/CSS specs?
The closest thing I see is :valid/:invalid but we can't really use it for consistency because of setCustomValidity() that can make any element invalid.
Comment 5 Jonas Sicking (Not reading bugmail) 2011-02-23 00:13:12 UTC
It just seems more consistent to me that the range selectors only apply if there is an actual range requirement.

If you want them to apply "when there could be ranges" you get into the somewhat fuzzy discussion of which types can have ranges.
Comment 6 Mounir Lamouri 2011-02-23 00:27:15 UTC
I think the input types that can have ranges are those that can have min and max applying.
But, to be clear, I'm fine with your proposition. It seems more complex than just doing it per-type but it also makes more sense (at least, the logic is more strict).
Comment 7 Jonas Sicking (Not reading bugmail) 2011-02-23 02:49:41 UTC
More complex in what sense? To implement or to use? If it's the former then that doesn't worry me so much. Unless you think it's prohibitively complex (e.g. perf). You're likely the one to implement in gecko, so you're the best judge of that ;-)
Comment 8 Mounir Lamouri 2011-02-25 00:28:13 UTC
Both actually.
That would be the first pseudo-class I see that applies or not depending on so much conditions (has to be <input>, with type={number,range,...}, with max or min defined and set to a valid value, then depending on the element's value, one of the two classes will apply). But I'm far from being experienced on that field so I trust your judgment.
For implementation, the real issue is the min/max validity which can't be checked too often so depending on the UA, it might be more or less a pain. For Gecko, we will have to keep a flag telling us if those attributes have valid values for the current type.
Comment 9 Jonas Sicking (Not reading bugmail) 2011-03-15 21:02:07 UTC
I'm not sure I agree that it's that many conditions. Conceptually it's just one condition, "has a defined range". What you are proposing is "is of type that supports ranges" which IMHO isn't obviously a simpler condition.

Additionally, the :-moz-ui-invalid pseudo classes we have in gecko have a much more complex set of conditions, though there too the concept is the simpler "does it make sense to render invalid-UI".
Comment 10 Ian 'Hixie' Hickson 2011-05-06 20:08:47 UTC
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Partially Accepted
Change Description: see diff given below
Rationale: I tightened up the definitions to match CSS3 UI more closely (which basically means I did what Jonas suggested).
Comment 11 contributor 2011-05-06 20:09:37 UTC
Checked in as WHATWG revision r6106.
Check-in comment: Make :in-range and :out-of-range definitions match the spec that introduced them.
http://html5.org/tools/web-apps-tracker?from=6105&to=6106
Comment 12 Michael[tm] Smith 2011-08-04 05:17:18 UTC
mass-move component to LC1