fix: pass polyfill options through to constructed-stylesheet shadow runs - #443
Conversation
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.
✅ 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.
|
|
@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. |
No, we could do that as well. Shall i change it to that? |
Yes, please! I think parity makes sense. |
Done, please review. |
jamesnw
left a comment
There was a problem hiding this comment.
Thanks for making this change!
Fixes #442
The polyfill runs set up by
patchAndPolyfillConstructedStylesheets()calledpolyfill({ roots: [shadowRoot] })with an explicit options object, sopolyfill()never fell back towindow.ANCHOR_POSITIONING_POLYFILL_OPTIONS. Global options such aspositionAreaContainingBlock: falsewere silently ignored for shadow roots with adopted stylesheets — theirposition-areatargets were still wrapped in<polyfill-position-area>.patchAndPolyfillConstructedStylesheets()now accepts options and passes them down topatchHostConnectedCallback(), which forwards them to eachpolyfill()run, overridingrootswith the shadow root being positioned. The options default towindow.ANCHOR_POSITIONING_POLYFILL_OPTIONS, matchingpolyfill(), so the no-argument case picks up the global.The new parameter is a backward-compatible addition to the public
/fnexport.Includes e2e tests covering both paths: options set globally, and options passed explicitly (with a conflicting global, so the explicit argument has to win).