- From: Tab Atkins Jr. via GitHub <sysbot+gh@w3.org>
- Date: Mon, 28 Jan 2019 16:47:03 +0000
- To: public-css-archive@w3.org
> I'm interesting about a way to silently have the '& ' prefix on children element. Unfortunately this isn't possible, for reasons explained in the Nesting proposal; selectors and declarations have overlapping grammars and can't be told apart with any finite number of tokens; you have to look forward an *unbounded* amount before you can be sure in all cases whether you're looking at a selector or a declaration. In particular, seeing something like `color:blue` might be the `color` property, or it might be a `<color>` element selector with a `:blue` pseudoclass selector; you can't tell which it is until you get to a `{` (indicating it was a selector) or a `;` (indicating it was a declaration). Requiring the `&` in front (or `@nest`) solves this, as it means you can tell *immediately* that you're in a nesting-rule situation, rather than a declaration. Additionally, the `&` is useful to have because it clarifies your intent. There's a huge difference between `.foo :hover` and `.foo:hover`, but in `.foo { :hover {...}}` it's not immediately clear which one you intended. With `&` you instead have either `& :hover` or `&:hover` on the inner rule, and it's immediately obvious. So even if there weren't any parsing issues, I'd still want to require an `&` in the selector. > [idea about `@import`] Currently, @import can't even be placed *between* rules, let alone within them; all `@import` rules have to be at the very beginning of the document. This greatly simplifies implementation, as it means you don't have to track specificity across stylesheets; all imported sheets just come *before* the sheet that imports them, identical to just having multiple `<link>` elements in order. So, it's unlikely that `@import` will be changed in this way. If it ever does, it'll be a separate proposal that relaxes the `@import` restrictions in general, allowing it to show up between rules as well. -- GitHub Notification of comment by tabatkins Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2909#issuecomment-458208325 using your GitHub account
Received on Monday, 28 January 2019 16:47:04 UTC