Closed paulmillr closed 6 years ago
I couldn't find in the docs, nor confirm in other comipilers (tested only in less.app and less.php online demo) but I was able to achieve this with pain old &
that seems to work like a string, so:
.photos {
&-photo {
&-description {}
}
}
should compile to:
.photos {}
.photos-photo {}
.photos-photo-description {}
tl; dr: I propose to add an option that would compile this
to
What
In the most of today's heavy webapps, styles are very unstructured.
Dynamic CSS-like languages (less, sass, stylus) allow selector nesting, like:
Cost
It is an awesome and very structured way to describe styles.
Although, that approach has one major issue: the descendant selector is the most expensive selector in CSS. Really, it is dreadfully expensive. While this expensiveness is totally OK for small sites, it is a pain for big and fat ones.
In my webapps, I usually use five and more indented levels. Comprehensive example: paulmillr/vk-contest-2011/css/style.css#L450.
Idea
To deal with performance issues in big webapps, user would be able to use some new compilation option, like
--mangle
, that would mangle all descendant selectors with some symbol, that would be used for namespace resolution. Like_
or-
.So, instead of this
it would be much more comroftable to write something like this: