[resize-observer] What should the fragment-aware behavior be when there are no fragments?

Open
#7,734 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
css
Domain
web-dev

Research direction

Start with the linked CSSWG issue 3673 comment and the ResizeObserver fragment-size behavior described here. Compare the empty-array and zero-size alternatives, including the linked react-breakpoints usage, and document a resolved behavior for elements with no fragments.

Written by the indexing model from the issue text.

Description

Needs Edits resize-observer-1

See https://github.com/w3c/csswg-drafts/issues/3673#issuecomment-467221565

RES0LVED: Option 1; contentBox is an array of fragment sizes

So if a box has 1 fragment then the array has length 1, if it has 2 fragments it has length 2, and so on.

What if the element has no fragments like in display: none? Then getting an empty array would probably make the most sense.

Likewise for non-atomic inlines, which are considered to have a size of zero. Since this is not a real size it might make more sense to represent it as a lack of fragments.

I think it's also possible (e.g. with continue: discard) to have an element that generates a box, but no fragment is created.

The risk of an empty array is that right now with the non-fragment aware API we get an array of length 1 (a 0x0 size). I'm concerned that several web pages may be using contentBoxSize[0].inlineSize without checking contentBoxSize.length. See https://github.com/envato/react-breakpoints/blob/5b25ede569801efa0030e42e49b9fca08308dc47/src/useBreakpoints.ts#L99-L120 for an example.

That said, elements with a size of 0x0 (either real or due to no box or inline box) weren't initially getting their ResizeObserver callback invoked before #3664, so it may not be a big deal if the callback now throws in the non-real 0x0 case.

Dominant language
Bikeshed
Stars
4.9k
Forks
816
Avg merge
2d 18h
Merged PRs (30d)
24

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.

More from w3c/csswg-drafts

All issues in w3c/csswg-drafts

Similar issues

More Web Dev issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.