Re: [csswg-drafts] [css-nesting] Problem with mixing properties and selectors (#8249)

> Try this in a browser that doesn't support nesting:

Yes, your stylesheet will be incredibly broken if you try and use Nesting in an older browser. Eating the following declaration is the least of your worries, large portions of your sheet simply won't parse.

> or this in a browser that does:

Yeah that's fine, it'll parse the rule and stop. (In older browsers it'll eat the next declaration.)

If the element name was a valid property name, that's also fine. We'll *try* to parse it as a declaration, declare it invalid, then restart and parse as a rule, stopping at the correct place. 

The only problem is if we somehow create a property whose name+value looks like a valid rule followed by a different declaration. This is trivial to avoid with a completely reasonable design restriction (if we ever allow a top-level {} in a property value, only allow it at the whole property value; if we're careful with the grammar we can allow stuff before it), but even *without* that restriction it's honestly hard to imagine a syntax we could ever design that would actually confuse the parser here.

The one case we have to be careful is with custom properties, since we can't control what they're doing, but that's also fine in practice since custom elements can't have dashed-ident names.

I documented all of this in <https://github.com/w3c/csswg-drafts/issues/7961#issuecomment-1490495722>. The strategy we're advocating here is *very* robust, actually.

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


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

Received on Wednesday, 5 April 2023 23:02:09 UTC