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

Charts fail to render when Object prototype is frozen #11528

Closed
AugustasIgneris opened this issue Oct 4, 2023 · 2 comments
Closed

Charts fail to render when Object prototype is frozen #11528

AugustasIgneris opened this issue Oct 4, 2023 · 2 comments

Comments

@AugustasIgneris
Copy link

Expected behavior

Chart.js should be able to cope with Object prototype frozen. Object prototype constructor should not be reassigned.

Current behavior

The library attempts to reassign Object prototype constructor and thus breaks if Object prototype is frozen.

Reproducible sample

https://codepen.io/AugustIgner/pen/XWoxROZ?editors=1111

Optional extra steps/info to reproduce

Freeze the Object prototype before rendering a chart: Object.freeze(Object.prototype)
Updating the chart then causes errors such as:

Uncaught TypeError: Cannot assign to read only property 'constructor' of object '#<Object>'
    at qe (chart.umd.js:13:22633)
    at Object.get (chart.umd.js:13:20541)
    at Xe (chart.umd.js:13:22512)
    at chart.umd.js:13:21853
    at chart.umd.js:13:21893
    at qe (chart.umd.js:13:22618)
    at Object.get (chart.umd.js:13:21187)
    at an (chart.umd.js:13:84298)
    at An.buildOrUpdateControllers (chart.umd.js:13:93384)
    at An.update (chart.umd.js:13:94319)

Possible solution

No response

Context

To prevent prototype pollution we freeze Object prototype. Chart.js is the only library we use that has an issues with that.

chart.js version

4.4.0

Browser name and version

No response

Link to your project

No response

@EricWittrock
Copy link
Contributor

I will work on this issue.

@LeeLenaleee
Copy link
Collaborator

Resolved in: #11754

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants