[csswg-drafts] [css-viewport] Behavior of `segments` when there is only 1 segment (#11957)

bramus has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-viewport] Behavior of `segments` when there is only 1 segment ==
The spec currently reads the following for [the `segments` property of `window.viewport`](https://drafts.csswg.org/css-viewport/#segments)

> 4. Returns `null` if there is only a single viewport segment and abort these steps.

This very counterintuitive when trying things out and I would have expected for 1 segment to reported, with its values at origin `0,0` and its `width`/`height` equal to the `innerWidth` and `innerHeight` respectively.

Admittedly the fallback authors can do is pretty easy here, yet I still find it weird to return `null` as currently specced. That keyword is typically reserved to indicate that _there is no value_ or _there is no such thing_, whereas there is definitely 1 segment here.

Having it return 1 segment would also help distinguish the 1 segment situations vs “the document is currently not active” situation. The latter also returns `null`, as per spec:

> 1. If the [Viewport](https://drafts.csswg.org/css-viewport/#viewport%E2%91%A0)’s associated [Document](https://dom.spec.whatwg.org/#document) is not [fully active](https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active), return `null`

In summary, the proposed change is to return 1 segment instead of `null` when there is only 1 segment.

/cc @darktears

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11957 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 18 March 2025 16:48:56 UTC