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

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.

~TJ

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