W3C home > Mailing lists > Public > www-style@w3.org > June 2016

Re: @else in Media Queries

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Tue, 21 Jun 2016 10:22:52 -0700
Message-ID: <CAAWBYDABJB33GtE1kXEmztc_Hwj_DNSpLjJuJ_sL3tHfkc4G1Q@mail.gmail.com>
To: Simon Pieters <simonp@opera.com>
Cc: Florian Rivoal <florian@rivoal.net>, Mark Brown <mark@mercurylang.org>, "www-style@w3.org" <www-style@w3.org>
On Tue, Jun 21, 2016 at 3:48 AM, Simon Pieters <simonp@opera.com> wrote:
> On Tue, 14 Jun 2016 07:41:44 +0200, Tab Atkins Jr. <jackalmage@gmail.com>
> wrote:
>
>> Right. Theoretically, sure, it's more robust, but it's the exact same
>> situation every other programming language has with something like:
>>
>> if(...) {
>>  ...
>> }
>> if(...) {
>>  ...
>> }
>> else {
>>  ...
>> }
>>
>> If you mistakenly delete only the middle if, the program will change
>> meaning, sure.  But in practice this doesn't seem to be anywhere near
>> hazardous enough to warrant protecting people against.  People just
>> don't screw this up very often.
>
>
> Maybe containment makes sense in the OM but not in the syntax. Can't we have
> it both ways?
>
> Given this stylesheet:
>
> @media (...) { ... }
> @else { ... }
>
> ...the OM contains only one CSSMediaRule, no sibling. Instead that rule has
> a property .else that points to the CSSElseRule (which can itself have
> further .else, and also a property to point to its owner). So if you remove
> the @media rule in the OM, the @else rule is removed with it.
>
> I suppose it is a bit confusing to have the syntax and OM have different
> structure, but I thought I'd bring it up as a possible way forward.

I'd strongly prefer not having the OM be gratuitiously different from
the syntax. That's just confusing for everyone, and makes it more
confusing to work with, not less - how do you add an @else rule to the
document via the OM? Can you just append it to the stylesheet and
magic happens, or do you need to get that final conditional rule,
chase its .else pointers until you hit a null, then set it to your new
rule?

Again, this is not a "problem" in any other language. It's not a
realistic editting hazard, and doesn't need special treatment in CSS.
People can handle sibling rules being implicitly linked, I promise.

~TJ
Received on Tuesday, 21 June 2016 17:23:42 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:52:47 UTC