Improve support of un-computed calc #128
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#115 adds basic support for uncomputed
calc ()
values, but only for those of type<dimension>
, ie. a<length-percentage>
like for thewidth
property, but not for those of type<length>
, like for theborder-width
property, or<percentage>
.This PR is only a draft, for several reasons.
There is no support for types that can be used in
calc
but which are nested within another type, such as an<angle>
or a<length-percentage>
(<color-stop>
) in a<gradient>
for thebackground-image
property.There is no support for
<hsla?()>
because its values are currently computed (see next point) to<rgba?()>
.Ideally,
calc
should be computed when possible (see WIP: Implement calc #101 ) to conform to the specification and browsers behavior.Some recent language features are used like array destructuring, and other features like
var
. So I'm not sure of the targeted environments that should be supported.Latest and stable versions, I guess?
<rgba?()>
and<hsla?()>
should be able to support a space as a separator for values other than the alpha channel (note that it would complicate the task of their parser), and a/
to separate the latter.This draft provides support for properties directly receiving (ie. not nested in another type) a value of type
<integer>
,<number>
,<color>
(only<rgba? ()>
),<length>
,<percentage>
(font-stretch
is an example but its values are not parsed bycssstyle
),<angle>
(offset-rotate
is an example but same as<percentage>
).This draft also fixes the two following issues:
rgba()
, if the alpha value is not supplied (eg.rgba(0, 0, 0)
), it is currently considered as invalid, because the parser checks for 4 argumentsrgba(0, 0, 0, 50%)
orrgba(0%, 0%, 0%, 50%)
outputrgb(0, 0, 0)
because50
is not divided by 100