Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESM leaks to the global scope #2743

Closed
LeaVerou opened this issue Nov 2, 2021 · 1 comment · Fixed by #2750
Closed

ESM leaks to the global scope #2743

LeaVerou opened this issue Nov 2, 2021 · 1 comment · Fixed by #2750
Labels
bug Something isn't working

Comments

@LeaVerou
Copy link
Contributor

LeaVerou commented Nov 2, 2021

Description

Even the ESM version of Apex Charts leaks two globals to the global scope: addResizeListener() and removeResizeListener().
These seem to originate here: https://github.com/apexcharts/apexcharts.js/blob/e9e7fefc7fcd5d94b6ad23eda3e19da07d250a83/src/utils/DetectElementResize.js

Furthermore, the very same script causes errors when Apex Charts is used in Shadow DOM.

I'd suggest ditching this altogether and using ResizeObserver with a polyfill for older browsers (it's already supported natively for 92% of users).

Reproduction Link

https://codepen.io/leaverou/pen/rNzYdXj?editors=0010
but literally any snippet would demonstrate the issuse.
In this pen I'm also logging the globals though.

@LeaVerou LeaVerou added the bug Something isn't working label Nov 2, 2021
@junedchhipa
Copy link
Contributor

Ah! this was the reason the ESM build was failing in some frameworks.
Thanks for pointing this out, we will look into this further.

junedchhipa added a commit that referenced this issue Nov 6, 2021
Replace old DetectElementResize script with ResizeObserver, fixes #1332 and #2743
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants