GoogleChromeLabs / container-query-polyfill

A polyfill for CSS Container Queries
https://npm.im/container-query-polyfill
Apache License 2.0
1.13k stars 50 forks source link

Script breaks Leaflet implementation #89

Open MajPay opened 2 weeks ago

MajPay commented 2 weeks ago

When adding the polyfill like this:

<script src="container-query-polyfill.modern.js" async></script>

it may interfere with Leaflet implementations as it writes a function to the global "L" variable.

In my concrete case window.L is a function with the following content:

function L(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128||95===e}

When i add the script tag with type="module" it works but i dont know if it works correctly that way...

Do you have any advice or could you provide an update, that avoids messing with the window object?

MajPay commented 2 weeks ago

If someone has the same issues: I migrated to this loading for the moment:

<script type="module">if (!CSS.supports('container-type: inline-sizes')) import('container-query-polyfill.modern.js');</script>