Re: [mediaqueries] Unintuitive evaluation in boolean context

On Wed, Aug 13, 2014 at 9:01 AM, David Bokan <bokan@google.com> wrote:
> Hello,
>
> I'm implementing the newly added any-hover and any-pointer media
> features in Media Queries Level 4. When it comes to evaluating these
> features in a boolean context, I find the specified behavior to be
> unintuitive. From the spec on evaluating in a boolean context (2.4.2):
>
> "If the feature would be true for the number 0, a dimension with the
> value 0, or the keyword none, the media feature evaluates to false. If
> it would be true for any values other than the above, it evaluates to
> true. Otherwise, it evaluates to false."
>
> This means if a user has a mouse and some other non-pointing input
> device (e.g. voice recognition?), '@media (any-pointer)' would
> evaluate to false. As a developer, I would expect that to evaluate to
> true if there is any pointing device available to the UA. This could
> be made intuitive by changing the order of the statements in the spec:
>
> "If it would be true for any values other than the number 0, a
> dimension with the value 0, or the keyword none, it evaluates to true.
> If the feature would be true for any of the values above, the media
> feature evaluates to false. Otherwise, it evaluates to false."
>
> Is the existing ordering intentional? As far as I can tell this
> wouldn't affect any other media features.

I'm actually not sure where that ordering came from. I may have simply
made it up, as it doesn't appear in MQ3.

You're right that it doesn't affect any existing MQs, as they all have
discrete values; any-pointer/hover are the first MQs to feature
multiple values being true at once.  I'm fine with changing it to be
simpler.  We can simplify your text further:

"If it would be true for any values other than the number 0, a
dimension with the value 0, or the keyword 'none', the media features
evaluates to true. Otherwise, it evaluates to false."

~TJ

Received on Tuesday, 19 August 2014 14:59:17 UTC