Fix bounds-checking for opacify() et al.

This commit is contained in:
Natalie Weizenbaum 2016-11-14 22:46:58 -08:00
parent 2edc6210d3
commit d71e530622
3 changed files with 10 additions and 3 deletions

View File

@ -1,3 +1,8 @@
## 1.0.0-alpha.5
* Fix bounds-checking for `opacify()`, `fade-in()`, `transparentize()`, and
`fade-out()`.
## 1.0.0-alpha.4
* Add support for bracketed lists.

View File

@ -986,7 +986,8 @@ SassColor _opacify(List<Value> arguments) {
var color = arguments[0].assertColor("color");
var amount = arguments[1].assertNumber("amount");
return color.changeAlpha(color.alpha + amount.valueInRange(0, 1, "amount"));
return color.changeAlpha(
(color.alpha + amount.valueInRange(0, 1, "amount")).clamp(0, 1));
}
/// The definition of the `transparentize()` and `fade-out()` functions.
@ -994,7 +995,8 @@ SassColor _transparentize(List<Value> arguments) {
var color = arguments[0].assertColor("color");
var amount = arguments[1].assertNumber("amount");
return color.changeAlpha(color.alpha - amount.valueInRange(0, 1, "amount"));
return color.changeAlpha(
(color.alpha - amount.valueInRange(0, 1, "amount")).clamp(0, 1));
}
/// Converts a Sass string index into a codepoint index into a string whose

View File

@ -1,5 +1,5 @@
name: sass
version: 1.0.0-alpha.4
version: 1.0.0-dev
description: A Sass implementation in Dart.
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/sass/dart-sass