Add positionAreaContainingBlock option#428
Draft
jpzwarte wants to merge 1 commit into
Draft
Conversation
Add a `positionAreaContainingBlock` polyfill option that controls whether a `position-area` target is wrapped with an element approximating the containing block that `position-area` natively creates. - `true` (default): always wrap; matches the current behavior most closely. - `false`: never wrap; the polyfill computes and applies inset values directly on the target instead. - `'auto'`: wrap only targets whose styles resolve against the containing block (percentage sizes, `auto`/percentage margins, percentage padding, or `stretch`/`anchor-center` self-alignment); other targets are positioned directly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
✅ Deploy Preview for anchor-position-wpt canceled.
|
✅ Deploy Preview for anchor-polyfill ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
positionAreaContainingBlockpolyfill option that controls whether aposition-areatarget is wrapped with an element approximating the containing block thatposition-areanatively creates. The wrapper is correct but can interfere with author CSS that depends on the target's position in the DOM tree (direct-child/sibling combinators, the original parent's flex/grid layout, etc.). This option makes that tradeoff configurable.true(default): always wrap the target — matches the current behavior most closely.false: never wrap; the polyfill computes and applies inset values directly on the target instead. Avoids the extra element, but styles that resolve against the containing block (percentage sizes,auto/percentage margins, percentage padding, orstretch/anchor-centerself-alignment) won't match native behavior.'auto': wrap only targets whose styles resolve against the containing block (same heuristics as above); position all other targets directly.Implementation notes
polyfill.ts: new public option onAnchorPositioningPolyfillOptions(+ normalized). InapplyAnchorPositions, aposition-areatarget positions viawrapper ?? target; unwrapped targets resolve alignment to physical inset values via the newresolveAxisInsetValueshelper.position-area.ts: newPositionAreaContainingBlocktype;isContainingBlockDependentDeclarationheuristic + property lists;addPositionAreaDeclarationBlockStylesemits the wrapped/unwrapped/both declaration sets; newmarkPositionAreaTarget,activeTargetStyles, andPOSITION_AREA_TARGET_ATTRIBUTEfor the unwrapped path. Wrapper insets renamed--pa-value-*→--pa-wrapper-*so a shared'auto'selector's target insets don't collide.parse.ts: collects containing-block-dependent selectors during the AST walk and computesneedsWrapperper target in'auto'mode.Testing
tsc --noEmit: cleaneslint: cleanmarkPositionAreaTarget,dataForPositionAreaTarget,activeTargetStyles)npm run build: succeedsfalse/'auto'rendering was not run and should be confirmed before merge. Porting the e2e tests for the new modes is a follow-up.🤖 Generated with Claude Code