Skip to content

Commit

Permalink
[Color 4] Be stricter about slash-separated strings (#3862)
Browse files Browse the repository at this point in the history
Co-authored-by: Carlos (Goodwine) <2022649+Goodwine@users.noreply.github.com>
  • Loading branch information
nex3 and Goodwine committed May 10, 2024
1 parent 31eefa5 commit e778899
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
5 changes: 5 additions & 0 deletions accepted/color-4-new-spaces.changes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Draft 1.19

* Be stricter about which colors are allowed with slash-separated strings at the
end.

## Draft 1.18

* Treat missing channels as distinct from 0 for `==`-equality for colors.
Expand Down
30 changes: 13 additions & 17 deletions accepted/color-4-new-spaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -1138,29 +1138,25 @@ The procedure is:

* If the last element of `input` is an unquoted string that contains `/`:

> This solves for a legacy handling of `/` in Sass that would produce an
> unquoted string when the alpha value is a CSS function such as `var()`,
> when either value is `none`, or when using relative color syntax.
* Let `split-last` be the result calling `string.split()` with the last
element of `input` as the string to split, and `/` as the separator.

* If `split-last` has two items, and one or both items are an unquoted
string that's case-insensitively equal to 'none':

> Special handling for `none/none`, `none/<number>`, and `<number>/none`.
* If either item in `split-last` can be coerced to a number, replace
the current value of the item with the resulting number value.

* If any item in `split-last` is not a number or an unquoted string
that's case-insensitively equal to 'none', return an unquoted string
with the value of `input`.
* If `split-last` doesn't have exactly two items, return an unquoted string
with the value of `input`.

* Otherwise, let `alpha` be the second element in `split-last`, and
append the first element of `split-last` to `components`.
> This ensures that `rgb(1 2 calc(var(--a) / var(--b)) / var(--c))` is
> handled correctly after the final expresssion is fully converted to a
> string due to legacy `/` behavior.
* Otherwise, return an unquoted string with the value of `input`.
* If either item in `split-last` can be coerced to a number, replace
the current value of the item with the resulting number value.

> This solves for a legacy handling of `/` in Sass that would produce an
> unquoted string when the alpha value is a CSS function such as `var()`
> or when either value is `none`.
* Let `alpha` be the second element in `split-last`, and append the first
element of `split-last` to `components`.

* Otherwise, if the last element of `input` has preserved its status as two
slash-separated numbers:
Expand Down

0 comments on commit e778899

Please sign in to comment.