Re: Nesting declaration blocks

* Tab Atkins Jr. wrote:
>Of course, CSS has a big problem with selector nesting like in my
>first example - it breaks the core grammar pretty badly.  (It might
>also require arbitrary lookahead, but I'm not sure of that.)
>
>Discussing this around the team recently, though, we hit on a possible
>solution - @-rules.  I believe that nesting @-rules in a decl block is
>officially against the core grammar right now, but we discussed this
>back in the April ftf and kinda-sorta agreed to change this, with the
>recommendation that @-rules in decl blocks be put at the end, where it
>would break in a controllable way.
>
>Using @-rules, you could introduce nesting with only the minimal
>grammar breaking we talked about.  It would look something like this:
>
>#header {
>  prop: value;
>  @nest(img) {
>    prop: value;
>  }
>  @nest(> nav) {
>    prop: value;
>    @nest(> ul) {
>[...]

It seems http://lists.w3.org/Archives/Public/www-style/2004Jan/0018.html
my proposal for @context is a good bit simpler, it has a nicer name, it
does not require changing the core syntax, you do not have to put parens
around the selector-ish thing that sets the context and it allows you to
use the normal syntax within the at-rule, which makes it easier to embed
other style sheets (think copy and paste, SSI, or @import, if that's to
be allowed). For some things you might need an additional rule inside to
allow for some of the things you are proposing, but then so does your
proposal (say `@here` optionally followed by a selector-ish thing to key
the context selector to the current context selector).

Now if you had started out with the use cases that should be addressed,
we could discuss them first and then compare syntax proposals once there
is agreement what the syntax actually needs to support and how easy it
should make the various things. I am more interested in getting rid of
all the `.event-definition` in a style sheet such as

  http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221/spec.css

That would require removing all of those and wrapping the tail of the
style sheet in `@context .event-definition { ... }`. With your syntax
it's a lot more work and the result would be harder to read and parse.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 

Received on Tuesday, 19 October 2010 00:32:34 UTC