W3C home > Mailing lists > Public > www-style@w3.org > April 2015

Re: [css-cascade][mediaqueries] Allow custom mq before @import?

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 15 Apr 2015 08:51:51 -0700
Message-ID: <CAAWBYDBKpn_fgTF_sB-jUrxzefatLBaMzQ_+X7w7xX9SGHSXyA@mail.gmail.com>
To: Glen Huang <curvedmark@gmail.com>
Cc: www-style list <www-style@w3.org>
On Wed, Apr 15, 2015 at 4:50 AM, Glen Huang <curvedmark@gmail.com> wrote:
> I see the rationale. Thanks.
> You mentioned the possibility of custom media being redefined. I can't help but wonder how it works:
> ```
> @import "def.css";
> @import "redef.css" (--foo);
> @import "foo.css" (--foo);
> ```
> def.css
> ```
> @custom-media --foo true;
> ```
> redef.css
> ```
> @custom-media --foo false;
> ```
> Will this cause "foo.css" not being imported?

Good question!  The spec needs to be clarified, but an @custom-media
rule inside of a MQ block "indirectly depends" on the features tested
by the MQ block, so you're not allowed to be circular with that
either.  Since a conditional import is identical to an unconditional
import that wraps its contents in a MQ block, this means that the line
in redef.css is invalid due to circularity, and (--foo) stays true.

> Also, being able to using custom media in other places sounds wonderful, but does it have to be specified in a <meta>? Could a <style>, placed at an early position of <head>, containing the custom media definitions, be enough to make the custom media queries available document wide?

Maybe; the issue is just making it easy enough for the preload scanner
in browsers (which is intentionally fairly dumb and fast) to get hold
of it.  Parsing a stylesheet enough to find the @custom-media rules
might be too much, which is why I'm currently thinking of using a
<meta>.  But maybe it's ok!  We'll find out.

Received on Wednesday, 15 April 2015 15:52:37 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:53 UTC