-
Notifications
You must be signed in to change notification settings - Fork 682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css-nesting-1] consider dividing future selector syntax and future declaration syntax differently #8251
Comments
This post makes the assumption that the rules we set down today are unchangeable in the future. This isn't the case! We can definitely change things in the future, we just face possible compat pain. However, introducing a new syntax produces compat pain anyway (older browsers won't understand it and will throw it out as invalid), so the important question is just if there's a meaningful behavior difference between "syntax is reserved for properties but unused and currently invalid" and "syntax is reserved for selectors but unused and currently invalid". I argue that there is not. The behavior defined for properties and blocks by Option 3 right now is:
So, say we introduce a new The only case where the behavior is different is if there was a {} block inside the property value. Before nesting, Only something like All this is to say: we're actually pretty fine to leave the distinction as it currently is, and adjust things in the future if and when we need to. The compat impact is extremely minimal either way, so we don't need to try and plan for the future by tying our hands further today. |
Also as a secondary concern, people today use all sorts of ASCII garbage as a "commenting" mechanism for properties. Writing So, any future extensions to property syntax that try to add a glyph before the property name need to deal with the potential compat impact of this invalid CSS in the wild. (Nesting gets away with having these invalid declarations trigger style rules because the rest of the declaration won't look like a valid style rule, and we have the early exit if we see the In other words, the syntax space of "declarations, but we put a glyph at the beginning" is already pretty decently poisoned and probably a space we want to avoid. So, having Nesting consume that syntax space more explicitly doesn't actually reduce our usable options as much as it might look. |
+1 to everything @tabatkins said. I don't think we should change the split, “symbolic vs letter start” is a really clear and easy way to define the division, and as he explains here (and I explain in #8249 (comment)) we can change the split later if there's a particular symbol we want to switch into a declaration start character. We should probably figure out what we want to do with numbers and dimensions, though. :) They're neither idents nor symbols, and neither has precedent for using them, so I could go either way. |
This is a change to long-established error recovery. Currently we always parse until the next |
A fundamental problem with kicking the can down the road as to which symbols are reserved for properties vs selectors (or refining the rules today), is that it precludes us from ever using the same symbol in both places with different meanings. e.g. using a |
This isn't correct. Properties have always been able to have {} blocks inside of themselves. At least, it's certainly been valid per Syntax since I first wrote the spec years ago. Edit: Finally went and re-verified CSS2 - {}-blocks were indeed allowed in properties per the Core Syntax (property values had the grammar |
I commented over in #8249, but a relevant point from that comment is:
So I believe we should bias towards triggering nested-rule parsing, and thus keep the current spec (which treats all of those currently-invalid-either-way tokens as being selectors). |
The CSS Working Group just discussed
The full IRC log of that discussion<fantasai> TabAtkins: I think this one is moot given previous resolutions, but if dbaron has anything to discuss<fantasai> dbaron: I'm fine with moot <fantasai> astearns: Anyone else with concerns? <dbaron> astearns: no change? <fantasai> RESOLVED: Close as no longer relevant. <dbaron> TabAtkins: changes already made in other issues |
One of the things that came up in today's discussion of issue #8248 of the "option 3" syntax proposal is Peter's point that it reserves nearly all of the future expansion space for selector syntax and very little of it for declaration syntax (where declarations are currently basically property:value pairs, possibly with
!important
at the end). I wanted to open this issue to explore dividing the future expansion space differently.The underlying problem is that Option 3's nesting syntax introduces places in CSS syntax that accept either declaration syntax or accept selector syntax (excluding selectors that begin with an identifier or a function). These syntaxes (thanks to the exclusion) currently do not overlap. However, barring adding further exclusions in the future, this means that future expansions of either selectors or the declaration syntax would need to fit within the rules we define for how we determine what is a selector versus what is a declaration. This means that we are constraining one or both of future selector syntax expansion or future declaration syntax expansion. Peter noted (as part but not all of his concern) that we were reserving the bulk of the space for selectors and very little for declarations.
A few initial notes:
!
,$
,%
,/
,<
,=
,?
,^
, and`
. There has been some discussion of the possibility that future combinator expansion might use/keyword/
syntax and thus end up using only one of those symbols. (Most of the others may be somewhat undesirable as combinators for various other reasons as well, although<
is certainly plausible from a syntax perspective.)The things that the Option 3 proposal currently reserves for declaration syntax are things beginning with:
The things that the Option 3 proposal currently reserves for selector syntax and needs to do so in order to support selectors that are valid today (including the
&
added by the nesting proposal) are things beginning with::
,&
,>
,+
,~
,|
,.
, and#
[
The things that the Option 3 proposal currently reserves for selector syntax but which are not required by selectors as they exist today and which could be used by future CSS syntax are things beginning with:
/
(see above about combinator expansion; probably desirable for combinators)<
(which is probably desirable to keep with>
, which is in the previous list)!
,$
,%
,=
,?
,^
, and`
(see above about combinator expansion, may be less desirable for combinators),
(
'
or"
I'm opening this issue to consider whether we should refine option 3 by moving some of the things in the final list into the space of things that are reserved for future declaration syntax rather than the space of things that are reserved for future selector syntax.
(Note that I've probably made some mistakes in the above lists of characters, and I expect to need to edit this comment later and document those edits below.)
The text was updated successfully, but these errors were encountered: