Re: [csswg-drafts] [css-nesting] Conflicts in proposal with Sass/Less

> Most "best-practice" style-writing I've seen suggests not really nesting at all, but to use single class identifiers in a BEM-way, like:

On the other hand, as expressed in the previous thread, the Sass maintainers consider that syntax (building up a single simple selector thru concatenation of characters) to have been a serious mistake that they wish they could undo. @chriseppstein explicitly stated that he's happy that CSS Nesting is rejecting this possibility.

Stepping away from the argument-from-authority, tho, that syntax is also *intrinsically ambiguous*. There's no way to tell, given a selector like `&foo`, whether that's meant to be adding a `foo` type selector to the parent selector, or if it's meant to be *appending the characters "foo" to the identifier of the last simple selector* in the parent selector. If you assume BEM is being used, you can make some assumptions that will often work (which is what Sass currently does), but CSS can't reasonably make such assumptions. `--header` might legitimately be the tagname of an element; the fact that it's currently not a valid HTML element name doesn't mean it wont' be in the future, or that it's not valid in some other language using CSS.

> One second thought, I do have a proposal.

Unfortunately, this doesn't solve the entire reason I have the "`&` must be first` requirement - the nested selector can be grammatically ambiguous with a declaration, requiring unbounded lookahead to decide which it is.

Also, this proposal is *even further away* from current preprocessor syntax, so I don't think it satisfies your original goal either.

GitHub Notification of comment by tabatkins
Please view or discuss this issue at using your GitHub account

Received on Thursday, 19 July 2018 20:27:20 UTC