Skip to content

ESM leaks to the global scope #2743

@LeaVerou

Description

@LeaVerou

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions