Skip to content

Charts fail to render when Object prototype is frozen #11528

Closed

Description

@AugustasIgneris

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

Activity

  1. EricWittrock commented on Apr 28, 2024

    @EricWittrock
    Contributor

    I will work on this issue.

  2. LeeLenaleee commented on Apr 30, 2024

    @LeeLenaleee
    Collaborator

    Resolved in: #11754

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions