Re: @else in Media Queries

Florian Rivoal <[email protected]>
Newsgroups gmane.comp.web.css.general
Message-ID <[email protected]>
> On Jun 11, 2016, at 16:38, Daniel Glazman <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.