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

Re: @else in Media Queries

From: Florian Rivoal <florian@rivoal.net>
Date: Sat, 11 Jun 2016 18:27:53 +0900
Cc: www-style list <www-style@w3.org>
Message-Id: <F98F3B17-E946-4776-9992-1DA1658839A1@rivoal.net>
To: Daniel Glazman <daniel.glazman@disruptive-innovations.com>

> On Jun 11, 2016, at 16:38, Daniel Glazman <daniel.glazman@disruptive-innovations.com> wrote:
> 
> On 11/06/2016 09:04, Florian Rivoal wrote:
> 
>> I think what's more problematic is if you have
>>  @media (...) {...}
>>  @media (...) {...}
>>  @else {...}
>> and some code that's unaware of @else just deletes the second @media,
>> changing the semantics.
> 
> Unaware or old-fashion, without knowledge of @else. Yes, absolutely.
> 
>> But I am not sure this is a downside of this proposal. The fact that it is strictly more expressive than what we had before sounds like an argument for it, not against it.
> 
> Earlier in this thread, someone mentioned "all programming languages".
> There's not a single programming language I use these days that
> lets you delete the two first lines preserving the two last ones in
> 
>  if (foo)
>    blah;
>  else;
>    other;
> 
> without choking. This is what I think we should avoid here.

Most other languages don't try to recover from arbitrary syntax. HTML and CSS do. I don't see why we should be less able to recover from a dangling @else than from an @i-don-t-exist {}.


> I don't
> want standalone @else rules to appear because an OM-based app or webapp
> hasn't been updated to deal with @else. We would break 20+ years of
> "deletion of a valid rule does not change validity of a sheet".

Again, we can just declare an dangling @else to be a valid construct that does nothing.

Besides, couldn't we just define things so that in the abscence of a particular flag saying that you know what you're doing, deleting an @media or an @supports or an @when also deletes the chained @elses by default?

> Again, I understand the rationale behind the proposal and how/why it
> can be useful to some users (although I'm not sure it's that critical
> and not sure it's worth the hassle) but I think there are issues to
> solve to have something balanced, well integrated to CSS and in
> particular its OM. I also understand that @else cannot be, ATM, inside
> @media (or @when or whatever) because an invalid rule would trash the
> @else block with it.

I am not sure that's actually true. Current browsers would discard the nested @else, but they would also discard @else following @media. New browsers can do whatever we want them to, so if we prefer nested @else, I don't think there's any reason we couldn't do that.

It was my impression though that most people preferred the non-nested version.

 - Florian
Received on Saturday, 11 June 2016 09:28:20 UTC

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