Skip to content

fix: pass polyfill options through to constructed-stylesheet shadow runs - #443

Merged
jamesnw merged 3 commits into
oddbird:mainfrom
jpzwarte:fix/442-global-options-ignored
Jul 24, 2026
Merged

fix: pass polyfill options through to constructed-stylesheet shadow runs#443
jamesnw merged 3 commits into
oddbird:mainfrom
jpzwarte:fix/442-global-options-ignored

Conversation

@jpzwarte

@jpzwarte jpzwarte commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #442

The polyfill runs set up by patchAndPolyfillConstructedStylesheets() called polyfill({ roots: [shadowRoot] }) with an explicit options object, so polyfill() never fell back to window.ANCHOR_POSITIONING_POLYFILL_OPTIONS. Global options such as positionAreaContainingBlock: false were silently ignored for shadow roots with adopted stylesheets — their position-area targets were still wrapped in <polyfill-position-area>.

patchAndPolyfillConstructedStylesheets() now accepts options and passes them down to patchHostConnectedCallback(), which forwards them to each polyfill() run, overriding roots with the shadow root being positioned. The options default to window.ANCHOR_POSITIONING_POLYFILL_OPTIONS, matching polyfill(), so the no-argument case picks up the global.

The new parameter is a backward-compatible addition to the public /fn export.

Includes e2e tests covering both paths: options set globally, and options passed explicitly (with a conflicting global, so the explicit argument has to win).

The polyfill runs triggered by patchAndPolyfillConstructedStylesheets()
passed an explicit options object, so polyfill() never fell back to
window.ANCHOR_POSITIONING_POLYFILL_OPTIONS and options like
`positionAreaContainingBlock: false` were silently ignored for shadow
roots with adopted stylesheets — targets were still wrapped in
<polyfill-position-area>. Merge the global options into those runs,
keeping the run scoped to the shadow root.
@netlify

netlify Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploy Preview for anchor-polyfill ready!

Name Link
🔨 Latest commit aef70f2
🔍 Latest deploy log https://app.netlify.com/projects/anchor-polyfill/deploys/6a637cbcd8afa30008886539
😎 Deploy Preview https://deploy-preview-443--anchor-polyfill.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploy Preview for anchor-position-wpt canceled.

Name Link
🔨 Latest commit aef70f2
🔍 Latest deploy log https://app.netlify.com/projects/anchor-position-wpt/deploys/6a637cbc64a9010008a56a6f

@jpzwarte jpzwarte changed the title Apply global polyfill options to constructed-stylesheet shadow runs fix: apply global polyfill options to constructed-stylesheet shadow runs Jul 24, 2026
@jamesnw

jamesnw commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

@jpzwarte Is there a reason to not also support passing in options to patchAndPolyfillConstructedStylesheets()? I'm trying to remember why we didn't support that when we implemented it.

@jpzwarte

Copy link
Copy Markdown
Contributor Author

Is there a reason to not also support passing in options to patchAndPolyfillConstructedStylesheets()?

No, we could do that as well. Shall i change it to that?

@jamesnw

jamesnw commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Is there a reason to not also support passing in options to patchAndPolyfillConstructedStylesheets()?

No, we could do that as well. Shall i change it to that?

Yes, please! I think parity makes sense.

@jpzwarte

Copy link
Copy Markdown
Contributor Author

Yes, please! I think parity makes sense.

Done, please review.

@jpzwarte jpzwarte changed the title fix: apply global polyfill options to constructed-stylesheet shadow runs fix: pass polyfill options through to constructed-stylesheet shadow runs Jul 24, 2026

@jamesnw jamesnw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making this change!

@jamesnw
jamesnw merged commit 31dc8f3 into oddbird:main Jul 24, 2026
10 checks passed
@jpzwarte
jpzwarte deleted the fix/442-global-options-ignored branch July 24, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] window.ANCHOR_POSITIONING_POLYFILL_OPTIONS is ignored when polyfill() is called from patchHostConnectedCallback

2 participants