File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed
Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change 66* Properly consider ` b > c ` to be a superselector of ` a > b > c ` , and similarly
77 for other combinators.
88
9+ * Deprecate use of ` random() ` when ` $limit ` has units to make it explicit that
10+ ` random() ` currently ignores units. A future version will no longer ignore
11+ units.
12+
913## 1.54.4
1014
1115* Improve error messages when passing incorrect units that are also
3842* Add partial support for new media query syntax from Media Queries Level 4. The
3943 only exception are logical operations nested within parentheses, as these were
4044 previously interpreted differently as SassScript expressions.
41-
45+
4246 A parenthesized media condition that begins with ` not ` or an opening
4347 parenthesis now produces a deprecation warning. In a future release, these
4448 will be interpreted as plain CSS instead.
Original file line number Diff line number Diff line change @@ -289,11 +289,28 @@ final _random = math.Random();
289289
290290final _randomFunction = _function ("random" , r"$limit: null" , (arguments) {
291291 if (arguments[0 ] == sassNull) return SassNumber (_random.nextDouble ());
292- var limit = arguments[0 ].assertNumber ("limit" ).assertInt ("limit" );
293- if (limit < 1 ) {
292+ var limit = arguments[0 ].assertNumber ("limit" );
293+
294+ if (limit.hasUnits) {
295+ warn (
296+ "math.random() will no longer ignore \$ limit units ($limit ) in a "
297+ "future release.\n "
298+ "\n "
299+ "Recommendation: "
300+ "math.random(math.div(\$ limit, 1${limit .unitString })) * 1${limit .unitString }\n "
301+ "\n "
302+ "To preserve current behavior: "
303+ "math.random(math.div(\$ limit, 1${limit .unitString }))\n "
304+ "\n "
305+ "More info: https://sass-lang.com/d/random-with-units" ,
306+ );
307+ }
308+
309+ var limitScalar = limit.assertInt ("limit" );
310+ if (limitScalar < 1 ) {
294311 throw SassScriptException ("\$ limit: Must be greater than 0, was $limit ." );
295312 }
296- return SassNumber (_random.nextInt (limit ) + 1 );
313+ return SassNumber (_random.nextInt (limitScalar ) + 1 );
297314});
298315
299316final _div = _function ("div" , r"$number1, $number2" , (arguments) {
You can’t perform that action at this time.
0 commit comments