Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How about:

  x = .nesting {
    color: hotpink;
  }

  y = x > .is {
    color: rebeccapurple;
  }

  y > .awesome {
    color: deeppink;
  }
plus:

  x = .nesting;
  y = x > .is;
  z = y > .awesome;

  x {
    color: hotpink;
  }

  y {
    color: rebeccapurple;
  }

  z {
    color: deeppink;
  }

The names x, y and z aren't ambiguous because they are lexically defined. They could be allowed to shadow tags:

  pre = .foo > .bar;
then from that point on, pre isn't the HTML tag, but the above definition. Or else tags could be reserved: cannot use those as names. (Causing trouble when new tags get introduced; bad idea.)

Regarding the @nest syntax, why couldn't it look like an attribute?

  ...sel... {
     color: blue;
     nest: > .whatever { ... }
  }
Or just the colon:

  ...sel... {
     color: blue;
     : > .whatever { ... }
  }
Why use containment to express the nesting? What is being nested is the selectors. The braces group something else: the attributes affected by selectors. Why would nested selectors have to go into those braces?

The + character at the start of a rule could mean "the selector of the previous rule":

  .nesting { color: hotpink }
  + > .is { color: rebeccapurple }
  + > .awesome { color: deeppink }
Or use a master outer brace for this:

  {
      .nesting { color: hotpink }
      > .is { color: rebeccapurple }
      > .awesome { color: deeppink }
  }
The understanding is that the rules grouped in the brace have a cumulative selector, rather than independent selectors.

Or what if braces just group, and @nest (or whatever) is required to indicate the selector stacking semantics:

  @stack {
     .nesting { color: hotpink; }
     > .is { color: rebeccapurple; }
     > .awesome { color: deeppink; }
  }
Now you can have N levels of selector refinement without N levels of syntactic containment. The containment is still available:

  @stack {
     .nesting { color: hotpink; }
     > .is { color: rebeccapurple; }
     {  
       /* parallel rules: not a stack */
       .awesome { color: deeppink; }
       .terrific { color: yellow; }
     }
     @stack {
       /* stack-in-stack, cross-producting. */
       .even { color: red; }
       .more { color: green; }
       .nested { color: blue; }
     }
  }
Here, because the nested @stack follows a block of parallel rules, a Cartesian product semantics can come into effect. That is to say, it is equivalent to:

  @stack {
     .nesting { color: hotpink; }
     > .is { color: rebeccapurple; }
     {  
       @stack {
         .awesome { color: deeppink; }
         .even { color: red; }
         .more { color: green; }
         .nested { color: blue; }
       }
       @stack {
         .terrific { color: yellow; }
         .even { color: red; }
         .more { color: green; }
         .nested { color: blue; }
       }
     }
   }
 
The @stack following a parallel rule causes the @stack to distribute into the parallel branches.

Kind of like Bash brace expansion:

  $ echo nesting-is-{awesome,terrific}-even-more-nested
  nesting-is-awesome-even-more-nested nesting-is-terrific-even-more-nested


I liked the colon as well but the problem is

  i {
    font-variant: italic;

    ::hover {
     color: pink;
    }
  }
Is that ::hover or : :hover? As in

  i::hover 
Or

  i :hover
I think strictly speaking it is clear (it's the first one, as : is mandatory), but it doesn't look clear.

Like

  input {
    border: 3000px groove purple;
    color: transparent;

    :::placeholder {
      color: revert;
    }
  }


The mandatory : could be followed by required whitespace, making :: a syntax error.

Or the whitespace could be strongly recommended, with implementations encouraged to diagnose if it is missing, at least in ambiguous-looking situations like ::hover. (Is that a forgotten space? Or a forgotten colon?)

You have a space in:

    border: 3000px groove purple;
    color: transparent;
So just for consistency, you want it here:

    /*empty prop name*/: ::placeholder {
      color: revert;
    }


Ah this is the problem I originally anticipated with : when I first came up with the idea too. You see the problem is then (if you force a space):

  div {
    color: blue;
    : :hover {
       color: red;
    }
  } /* (1) */
Is unable to represent

  div {
    color: blue;

    /:hover {
      color: purple;
    }
  } /* (2) */
(or if it (1) means (2) then it is unable to represent the A below)

In other words you can write

  <div>Hi<span>there</span></div> 
And using the first one get a red there on hover (A). But the second one intends to get a purple Hi there on hover (B). But You can't express that because the mandatory space clashes with the CSS (implicit) descendent combinator (space).


Why not both? - Zoidberg


The @stack idea together with the named selectors would be pretty comprehensive.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: