[csswg-drafts] [cssom-view] `getClientRects()` should return a flattened list of child rects for `display: contents` (#12040)

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

== [cssom-view] `getClientRects()` should return a flattened list of child rects for `display: contents` ==
Spec: https://drafts.csswg.org/cssom-view/#dom-element-getclientrects
Testcase: https://codepen.io/leaverou/pen/GgRPVgg

Currently, for `display: contents` elements, `getClientRects()` returns no rects, so `getBoundingClientRect()` returns an empty bounding box. This breaks literally every library or component doing anything related to positioning (e.g. popups, popovers, etc), as they typically rely on `getBoundingClientRect()`, which in turn is computed as a union of `getClientRects()`. It even breaks the UA devtools! 

This is not just an inconvenience, I think it's also not architecturally sound: for everything else (e.g. flexbox, grid, etc), `display: contents` basically "offloads" layout to the element's children, so it seems reasonable `getClientRects()` should do the same and return a flattened list of the rects of its children.

One concern at this point is web compat, but @tabatkins thought because it's limited to `display: contents` it may be okay.

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


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

Received on Wednesday, 2 April 2025 16:22:50 UTC