Skip to content

[css-values-4] snap a length as a border width: meaning of "Assert: len is non-negative."? #13795

Closed

Description

@romainmenke

see: https://drafts.csswg.org/css-values-4/#snap-a-length-as-a-border-width

Assert: len is non-negative.

What is the meaning/implication of Assert in this context?

Is the value invalid when negative?

Because step 2 explicitly has "do nothing" I am assuming it makes the value invalid, but this seems weird.

If the intention is to do nothing, it might be better to write as:

1. If len is negative, do nothing.
2. If len is an integer number of device pixels, do nothing.
...

@tabatkins

Activity

  1. changed the title [-][css-values-4] `snap a length as a border width`: meaning of "Assert: len is non-negative."[/-] [+][css-values-4] `snap a length as a border width`: meaning of "Assert: len is non-negative."?[/+] on Apr 12, 2026
  2. Loirooriol commented on Apr 12, 2026

    @Loirooriol
    Contributor

    It means that whatever invokes the "snap a length as a border width" algorithm should make sure that len is non-negative.

  3. romainmenke commented on Apr 12, 2026

    @romainmenke
    MemberAuthor

    Thanks!

    In that case this is somewhat related to: #13794

    Otherwise, identical to nearest, except that if A is positive (non-zero) and one of lower B or upper B is zero, choose the non-zero one, then snap as a border width.

    This can indeed be read as an assert that A must be positive and that in other cases there is no snapping to border width.

  4. fantasai commented on May 8, 2026

    @fantasai
    Collaborator

    It means that whatever invokes the "snap a length as a border width" algorithm should make sure that len is non-negative.

    ... This doesn't seem great? It should snap a negative number snap(N) same as -snap(|N|).

  5. fantasai commented on May 8, 2026

    @fantasai
    Collaborator

    Fixed in c196082

    @romainmenke @Loirooriol Please re-open if there's a problem remaining, but we think this handles it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions