-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document random($limit) behavior whe $limit has units (#664)
* document random($limit) behavior whe $limit has units * add breaking change section for random-with-units * add random-with-units link to sidenav
- Loading branch information
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
source/documentation/breaking-changes/random-with-units.md.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
title: "Breaking Change: Random With Units" | ||
introduction: > | ||
The `random()` function will no longer ignore units on the `$limit` argument | ||
in a future version. Passing a `$limit` with units is deprecated to ensure the | ||
compilation results don't change once the new behavior lands. | ||
--- | ||
|
||
[The `random()` function] has historically ignored units in `$limit` and | ||
returned a unitless value. For example `random(100px)` would drop "px" and | ||
return a value like `42`. | ||
|
||
A future implementation of Dart Sass will stop ignoring units for the `$limit` | ||
argument and return a random integer with the same units. | ||
|
||
[The `random()` function]: ../modules/math#random | ||
|
||
<% example(autogen_css: false) do %> | ||
// Future Sass, doesn't work yet! | ||
@debug math.random(100px); // 42px | ||
=== | ||
// Future Sass, doesn't work yet! | ||
@debug math.random(100px) // 42px | ||
<% end %> | ||
|
||
## Transition Period | ||
|
||
<% impl_status dart: '1.54.5', libsass: false, ruby: false %> | ||
|
||
First, the Sass compiler will emit a deprecation warning for previous uses of | ||
`random()` when the `$limit` argument has units. The warning will suggest a way | ||
to preserve the existing behavior and another way that emulates the future | ||
implementation. | ||
|
||
In Dart 2.0.0 passing a `$limit` number with units will be an error, and then in | ||
a future minor release the `random()` function will return a random integer the | ||
same units as `$limit`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters