w3c / w3c/csswg-drafts

[css-typed-om] Should min and max methods on CSSNumericValue preserve percentage values?

Open
#9,628 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

css-typed-om
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

CSSNumericValues have a min and a max method.

If min or max is called and all of the values are CSSUnitValues with the same unit, the steps of the method will return early with a CSSUnitValue with the minimum or maximum value respectively.

If all of the items in values are CSSUnitValues and have the same unit, return a new CSSUnitValue whose unit internal slot is set to this’s unit internal slot, and value internal slot is set to the minimum of the value internal slots of the items in values.

But, if the unit is percent we can't really know what value it will resolve against at this point. Since percentages might resolve against a negative basis, returning a CSSUnitValue with the minimum or maximum of the values could end up with the opposite result of what is expected (see simplify a calculation tree).

Should this step in the methods be skipped if the unit is percent?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CSS Typed OM definitions of CSSNumericValue min() and max(), then read the CSS Values 4 section on simplifying calculation trees. Determine whether the early-return rule is valid for percent units with potentially negative bases. Done means the Working Group resolves the question and the affected specification algorithm is updated accordingly.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
web-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.