Re: [csswg-drafts] consider dividing future selector syntax and future declaration syntax differently (#8251)

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:

* If you look like you're a property, we parse until the next `;` (or end of parent block). You can have `{}` inside of you; it doesn't do anything special parsing-wise.
* If you look like you're a style rule, we parse until the next `;` OR `{}` (or end of parent block). If we see a `;` we guessed wrong and you were actually an invalid property, so we throw it out and start parsing fresh from there. If we see a `{}` we know you were a rule, and start parsing fresh after that.

So, say we introduce a new `$foo: bar;` property syntax. Before Nesting, that would just be noticed as an invalid property, and we would consume tokens until we hit the `;` and throw it all out. After nesting, it's noticed as a style rule and we consume until we hit the `;`, at which point we throw it all out as invalid. Identical behavior in both cases.

The only case where the behavior is different is if there was a {} block inside the property value. Before nesting, `$foo: {} bar;` would be recognized as an invalid property, and we'd consume tokens until we hit the `;` and throw it all out. After Nesting, it's a style rule, and we consume until we hit the {}. Then we start parsing fresh and try to consume the `bar;` part - unless the content is shaped *exactly* right, it'll definitely look invalid *anyway*, and everything up to the `;` will get thrown out.  So virtually all outcomes *still* produce identical behavior in both cases, they just reach that via slightly different mechanisms.

Only something like `$foo: {} color: red;` will actually produce a meaningfully different parse in the two scenarios; Nesting will recognized the `color: red;` as a property while pre-Nesting would throw it away as part of the invalid-property junk.

------

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.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8251#issuecomment-1362023012 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 21 December 2022 19:57:44 UTC