w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.5k stars 661 forks source link

[css-values-5] Normalized attr() substitution value #10503

Open andruud opened 4 months ago

andruud commented 4 months ago

What do you get if you serialize the computed value of --x here?

<div data-x="calc(1px + 2px)">
div { --x: attr(data-x length); }

I think we expect eager simplification (3px), and generally we may need something like the equivalent token sequence (but for non-computed values)?

andruud commented 4 months ago

OK, I now see the attribute value needs to be a single token (surprising), which means the example in the first post was bad.

In that case, what about:

<div data-x="10.000px">
div { --x: attr(data-x length); }

Does this serialize as 10px or 10.000px?

andruud commented 2 months ago

Agenda+ on behalf of @tursunova.

tabatkins commented 3 weeks ago

IIRC, the "single token" thing was written in back in the day to simplify implementation; for whatever reason, impls didn't want to invoke their full CSS parser on attribute values. (Similarly, the color type is restricted to just hex colors and color name keywords.)

I suspect that whatever reasons impls had for avoiding that at the time are probably less pressing now, and we should just invoke the CSS parser normally? We invoke the CSS parser for a few other HTML attributes already anyway, like <meta name=color-scheme> or <img srcset>