Skip to content

[css-sizing] Resolved value of min size properties doesn't round-trip #11716

Open
@Loirooriol

Description

@Loirooriol
<!DOCTYPE html>
<button>Click me</button>
<div id="target" style="width: 100px; aspect-ratio: 1; border: solid">
  <div style="height: 200px"></div>
</div>
<script>
var target = document.getElementById("target");
document.querySelector("button").addEventListener("click", () => {
  target.style.minHeight = getComputedStyle(target).minHeight;
});
</script>

There is interoperability among Gecko, Blink and WebKit: the resolved value of min-height doesn't round-trip. Awful.

This is because of CSS Sizing 3: https://drafts.csswg.org/css-sizing-3/#valdef-width-auto

For backwards-compatibility, the resolved value of this keyword is zero for boxes of all [CSS2] display types: block and inline boxes, inline blocks, and all the table layout boxes. It also resolves to zero when no box is generated.

This was fine because min-height: auto used to behave as zero. But CSS Sizing 4 went and changed that, without taking care of the resolved value: https://drafts.csswg.org/css-sizing-4/#aspect-ratio-minimum

In order to avoid unintentional overflow, the automatic minimum size in the ratio-dependent axis of a box with a preferred aspect ratio that is neither a replaced element nor a scroll container is its min-content size capped by its maximum size.

Hopefully it's not too late to change.

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