segmentio / myth

A CSS preprocessor that acts like a polyfill for future versions of the spec.
4.32k stars 130 forks source link

CSS nesting support #14

Open matthewrobb opened 10 years ago

matthewrobb commented 10 years ago

Is this something that would be considered in Myth? Maybe as a flag-only feature or something?

garrettboatman commented 10 years ago

I believe Matt is asking about nested CSS? I would love this as well. (Also, nested pseudo-classes/elements)

jonathanong commented 10 years ago

there's stylus-like nesting support: https://github.com/visionmedia/css-whitespace

but not LESS-style. this is out of scope though since this module is meant to write pure CSS, and from I know, there's no plans for nesting support in CSS.

anthonyshort commented 10 years ago

I'd say it's out of scope. There aren't any specs for it and it's often considered bad practice when trying to manage specificity on large projects. We're not aiming for feature-parity with things like Sass or Less.

matthewrobb commented 10 years ago

It seems to have disappeared but there was a spec at some point: http://drublic.de/blog/the-css-hierarchies-module-level-3/

matthewrobb commented 10 years ago

The spec used to live here: http://dev.w3.org/csswg/css-hierarchies/

I have no idea where this went ....

matthewrobb commented 10 years ago

Here's some more proof lol: http://w3-org.9356.n7.nabble.com/CSS-Hierarchies-Selector-Nesting-Proposal-tt11495.html

anthonyshort commented 10 years ago

Haha damn, that would have been awesome. It would be great if the browser implemented it. Perhaps they could have managed the specificity behind the scenes.

ianstormtaylor commented 10 years ago

darn, would be happy to think about it if the spec is still being considered

ianstormtaylor commented 10 years ago

it moved here: http://rawgithub.com/tabatkins/specs/master/css-nesting/Overview.html

necolas commented 10 years ago

wouldn't this require a change to css-parse? i think it's risky to implement these not-even-w3c-draft specs in a preprocessor that aims to align itself with a knowable css future.

ianstormtaylor commented 10 years ago

yeah would be more ideal if they had been submitted and the first email thread back and forth had happened. the colors one is more critical to actually being useful, nesting not so much

sqageek commented 10 years ago

It would be great if nested css is provided

tj commented 10 years ago

@matthewrobb FWIW you could use css-whitespace (or a regular css nested variant) and pass it to myth after. It'll slow things town a bit from re-parsing but give you more or less the same result

shellscape commented 10 years ago

I'll throw my hat in the ring for this feature. This alone would keep us from ditching LESS (and I'd love to).

The spec has also moved here: http://rawgithub.com/tabatkins/specs/gh-pages/css-nesting/Overview.html

tj commented 10 years ago

oh weird, the nested {} is ... interesting haha, I suppose that's to get the older parsers to just barf and bypass? should be simple enough to implement, looks a little gross but hey

matthewrobb commented 10 years ago

I don't like how those spec pages show all the examples with single line nests when it seems more likely/common that people would do something like:

div {
    {
        p {}
    }
}
tj commented 10 years ago

yeah, blows that you need an extra level of wasteful indentation, not a huge fan of that

MoOx commented 10 years ago

So we got http://tabatkins.github.io/specs/css-nesting/ but need to wait this to appears here http://dev.w3.org/csswg/ since it's a big deal. I guess this will require serious modifications of https://github.com/reworkcss/css

Myhlamaeus commented 10 years ago

What about the matches-any pseudo-class? It has a similar effect and is probably easier to implement.

MoOx commented 10 years ago

@ileri We will keep this issue for the nesting feature. Please open an other issue for that.