Add positionAreaContainingBlock option#412
Conversation
…not wrap the element when using position-area
✅ Deploy Preview for anchor-polyfill ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for anchor-position-wpt canceled.
|
|
Thanks for taking a look at this! I haven't done a full review, but wanted to note the questions I will be considering when reviewing.
|
|
So my reasoning for this PR is as follows:
position-area: top;
position-try-fallbacks: bottom;
So i kind of see this as a trade-off: you lose the relative sizes a containing block gives you, but you gain not having a wrapper element and having to take that into account in a web component based design system. Since in our design system we so far always use CSS Anchor Positioning hand-in-hand with popover, it would like to have that trade-off. To answer you questions:
|
|
As an experiment i've added an "auto" setting. This checks if the target has any styling that is affected by the containing block. It seems to work:
|
Closes #411
Adds a
positionAreaContainingBlockoption (default:true) to control howposition-areais polyfilled.true(default): The target is wrapped with a<polyfill-position-area>element that approximates the containing block created byposition-area. Alignment is applied viajustify-self/align-selfon the target within that wrapper.false: No wrapper element is inserted. Instead, the polyfill resolves theposition-areaalignment to concrete inset values and applies them directly on the target. This avoids breaking selectors that depend on a direct DOM relationship (e.g.> target,+ target,:nth-child()), but comes with trade-offs around inset overrides, self-alignment, and overflow alignment (documented in the README andposition-area.html).