Description
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.