% unit is missing
I am a bit surprised % is not in the units json, maybe I am not aware of some differentiation? Feel free to close if that's the case
We can add it, but which categories should we put it in?
"%": {
"groups": [
"CSS Units",
"CSS Lengths"
],
"status": "standard"
}
Any more?
A percent sign (%) is not a unit since doesn't represent a quantity itself but always relative to another quantity. Also a number with a unit produces a <dimension>, at the same time % produces its own type – <percentage>. And a "unit" should be an identifier, but % is not an identifier.
See dimension and percentage definitions for more details.
Btw, percentage is not limited to a length but can be used for any quantity, the spec defines the following productions:
<length-percentage><frequency-percentage><angle-percentage><time-percentage>
And in syntaxes.json you also can find <number-percentage>.
This is getting even more confusing since houdini api calls it a percent and calls it a unit value
CSSStyleValue.parse('width', '10%') // CSSUnitValue {value: 10, unit: 'percent'}
We don't call a % a "unit" largely for historical reasons, but it effectively is. The Typed OM API does call it one for simplicity; otherwise I'd need to invent a new class for it that is otherwise exactly identical to the one for unit values. Note that Typed OM also calls "number" a unit, for the same reason, even tho plain numbers are definitely distinct from unit values.
All of this is to say, whether you categorize % as a "unit" or not is largely a matter of what makes the must sense for your particular case. That's no hard and fast answer.