Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mediaqueries-5] Type checking math functions resolving to a feature dimension value #11765

Open
cdoublev opened this issue Feb 23, 2025 · 2 comments

Comments

@cdoublev
Copy link
Collaborator

cdoublev commented Feb 23, 2025

A feature dimension value specified with a math function matches <dimension> in <mf-value>:

<mf-value> = <number> | <dimension> | <ident> | <ratio>

According to CSS V&U, a math function can only resolve to a subset of <dimension>:

A math function resolves to <number>, <length>, <angle>, <time>, <frequency>, <resolution>, <flex>, or <percentage> according to which of those productions its type matches.

So implementations should either expand <dimension> to this restricted set when it is produced by <mf-value>, or they should skip type checking a math function matching <mf-value>, since <mf-value> must be validated against the grammar of the specified feature value anyway.

This can be clarified or, <calc-sum> could be produced instead of <number> | <dimension> | <ratio>, which would be on par with *-progress(<mf-name>, <calc-sum>, <calc-sum>), which requires validating <calc-sum> according to the grammar of the specified <mf-name> (or only its numeric type? #10802).

This would mean that queries like @media (10vw + 1rem < width) {} or @media ((10vw + 1rem) < width) {} would work.

@tabatkins
Copy link
Member

So implementations should either expand to this restricted set when it is produced by , or they should skip type checking a math function matching , since must be validated against the grammar of the specified feature value anyway.

I don't understand what you're asking for here. A math function resolves to one of those types. Those types match <number> or <dimension>, which is what <mf-value> requires. So a valid math function (per its normal validity rules) is always a valid <mf-value>.

@cdoublev
Copy link
Collaborator Author

Right, sorry, <dimension> does not expand to these types. Each of these is a <dimension>.

My point is that for an input calc(1px) < width, a CSS parser processing the grammar would first see <number> and fail to get a match, then try to replace it with a math function but fail to match its numeric type, then see <dimension> and fail to get a match and is not allowed to replace it with a math function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants