w3c / csswg-drafts

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

[css-typed-om][css-values] What context is CSSNumericValue.parse(...) considered to have for its parse? #10753

Open weinig opened 1 month ago

weinig commented 1 month ago

In most (I believe all other) cases, when parsing a calc() expression there is a known "context" which is needed to determine the type of percentage values. This is needed to figure out if the type should be a dimension with a percent hint (like when parsing a width property), or raw percentage (like when parsing scale).

With CSSNumericValue.parse(...) however, there is no specified context.

How are percentages supposed to be interpreted when parsed in this way?

weinig commented 1 month ago

cc @tabatkins, @fantasai

tabatkins commented 1 month ago

Correct, there isn't a specified context, so the paragraphs conditioned on the context don't apply.

As far as I know, the behavior should work out either way - if you have a value that works due to having a known context, then parsing it without a known context then matching it against a grammar should always work as well. Getting that right has been difficult and subtle; if you find an instance where it fails, it's a spec bug.