Skip to content

Commit

Permalink
Fix round calc function and mark as accepted (sass#3587)
Browse files Browse the repository at this point in the history
  • Loading branch information
jathak authored May 25, 2023
1 parent 6a69595 commit e2b2777
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
12 changes: 12 additions & 0 deletions accepted/calc-functions.changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Draft 1.2

* Fix behavior of `round` to ensure it is backwards-compatible with the existing
global Sass function.

## Draft 1.1

* `mod`, `rem`, `atan2`, or `pow` should take two arguments instead of three.

## Draft 1

* Initial draft
18 changes: 9 additions & 9 deletions proposal/calc-functions.md → accepted/calc-functions.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Calculation Functions: Draft 1.1
# Calculation Functions: Draft 1.2

*([Issue](https://github.com/sass/sass/issues/3504))*

Expand Down Expand Up @@ -260,9 +260,9 @@ This algorithm takes a calculation `calc` and returns a number or a calculation.
> otherwise calculations' arguments must match the expected number.
* If `calc`'s name is `"sin"`, `"cos"`, `"tan"`, `"asin"`, `"acos"`, `"atan"`,
`"sqrt"`, `"abs"`, or `"log"` and `arguments` contains exactly a single number
with [known units], return the result of passing that number to the function
in [`sass:math`] whose name matches `calc`'s.
`"sqrt"`, `"abs"`, `"log"`, or `"round"` and `arguments` contains exactly a
single number with [known units], return the result of passing that number to
the function in [`sass:math`] whose name matches `calc`'s.

[known units]: #known-units
[`sass:math`]: ../spec/built-in-modules/math.md
Expand All @@ -277,16 +277,16 @@ This algorithm takes a calculation `calc` and returns a number or a calculation.
* If `number`'s value is positive, return `1`.
* If `number`'s value is negative, return `-1`.
* Otherwise, return a unitless number with the same value as `number`.

> In this case, `number` is either `+0`, `-0`, or NaN.
> To match CSS's behavior, these computations _don't_ use fuzzy comparisons.
* If `calc`'s name is `"atan2"`, `"pow"`, or `"log"`:

* If `calc`'s name isn't `"log"`, `arguments` has only one element, and it's
not an unquoted string or a `CalculationInterpolation`, throw an error.

* Otherwise, if `arguments` contains exactly two numbers with [known units],
return the result of passing that number to the function in [`sass:math`]
whose name matches `calc`'s.
Expand Down Expand Up @@ -336,7 +336,7 @@ This algorithm takes a calculation `calc` and returns a number or a calculation.
> Normally we allow unquoted strings anywhere in a calculation, but this
> helps catch the likely error of a user accidentally writing `round(up,
> 10px)` without realizing that it needs a third argument.
* Otherwise, set `number` and `step` to the two arguments respectively and
`strategy` to an unquoted string with value `"nearest"`.

Expand Down Expand Up @@ -412,7 +412,7 @@ This algorithm takes a calculation `calc` and returns a number or a calculation.
throw an error.

* If `calc`'s name is `"hypot"` and `arguments` are all numbers:

* If those arguments are mutually [compatible], return the result of calling
`math.hypot()` with those arguments.

Expand Down
7 changes: 0 additions & 7 deletions proposal/calc-functions.changes.md

This file was deleted.

0 comments on commit e2b2777

Please sign in to comment.