mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-08-06 17:37:39 +00:00
b791bcefdb
revert commit 1fe19578c2 which changed `anchor()` values to `position-area`.
I'm not sure what compelled me to do that change initially, except the easier to understand syntax. Hopefully it wasn't important.
But oddbird polyfill expects `anchor()` values, which it converts to pixel values for positioning.
27 lines
736 B
JavaScript
27 lines
736 B
JavaScript
/*
|
|
This file basically checks support for Anchor Positioning API in the browser,
|
|
and then loads the Oddbird polyfill if support is lacking.
|
|
*/
|
|
|
|
let polyfillPromise;
|
|
|
|
// look for `anchorName` in the computed styles
|
|
const supportsAnchorPositioning = ()=>'anchorName' in document.documentElement.style;
|
|
|
|
export const bootstrapAnchorPositioningPolyfill = ()=>{
|
|
if(supportsAnchorPositioning()) return Promise.resolve(false);
|
|
if(polyfillPromise) return polyfillPromise;
|
|
|
|
polyfillPromise = (async ()=>{
|
|
try {
|
|
const { default: polyfill } = await import('@oddbird/css-anchor-positioning/fn');
|
|
await polyfill();
|
|
return true;
|
|
} catch (error){
|
|
polyfillPromise = undefined;
|
|
throw error;
|
|
}
|
|
})();
|
|
|
|
return polyfillPromise;
|
|
}; |