mirror of
https://github.com/danog/sass-site.git
synced 2024-12-13 18:07:35 +01:00
25d33be440
* document random($limit) behavior whe $limit has units * add breaking change section for random-with-units * add random-with-units link to sidenav
38 lines
1.3 KiB
Plaintext
38 lines
1.3 KiB
Plaintext
---
|
|
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`.
|