Skip to content

Improve support of un-computed calc #128

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

Closed
wants to merge 1 commit into from
Closed

Conversation

cdoublev
Copy link

@cdoublev cdoublev commented Apr 23, 2021

#115 adds basic support for uncomputed calc () values, but only for those of type <dimension>, ie. a <length-percentage> like for the width property, but not for those of type <length>, like for the border-width property, or <percentage>.

This PR is only a draft, for several reasons.

  1. 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 the background-image property.

  2. There is no support for <hsla?()> because its values are currently computed (see next point) to <rgba?()>.

  3. Ideally, calc should be computed when possible (see WIP: Implement calc #101 ) to conform to the specification and browsers behavior.

  4. 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.

    The primary use case is for testing browser code in a Node environment.

    Latest and stable versions, I guess?

  5. <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 by cssstyle), <angle> (offset-rotate is an example but same as <percentage>).

This draft also fixes the two following issues:

  • in 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 arguments
  • rgba(0, 0, 0, 50%) or rgba(0%, 0%, 0%, 50%) output rgb(0, 0, 0) because 50 is not divided by 100

@codecov-commenter
Copy link

Codecov Report

Merging #128 (dbf82a3) into master (b527ed7) will increase coverage by 0.38%.
The diff coverage is 85.24%.

❗ Current head dbf82a3 differs from pull request most recent head baf63bc. Consider uploading reports for the commit baf63bc to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #128      +/-   ##
==========================================
+ Coverage   37.39%   37.78%   +0.38%     
==========================================
  Files          87       87              
  Lines        1182     1191       +9     
  Branches      227      234       +7     
==========================================
+ Hits          442      450       +8     
  Misses        633      633              
- Partials      107      108       +1     
Impacted Files Coverage Δ
lib/parsers.js 80.82% <85.24%> (+0.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b527ed7...baf63bc. Read the comment docs.

@cdoublev cdoublev closed this May 10, 2021
@cdoublev
Copy link
Author

Superseded by #140.

@cdoublev cdoublev deleted the issue-1 branch June 11, 2021 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants