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

addListener and removeListener should be only invoked on truthy values #11685

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

DAcodedBEAT
Copy link
Contributor

As reported in #11677, this issue is experienced in a few libraries integrating chart.js (such as #11295, samber/chartjs-plugin-datasource-prometheus#40, sgratzl/chartjs-chart-graph#79)

TypeError: Cannot read properties of null (reading 'addEventListener')
  at addListener(../../node_modules/chart.js/dist/chart.js:3234:8)
  at createProxyAndListen(../../node_modules/chart.js/dist/chart.js:3360:15)
  at DomPlatform.addEventListener(../../node_modules/chart.js/dist/chart.js:3406:21)
  at _add(../../node_modules/chart.js/dist/chart.js:6216:16)
  at <anonymous>(../../node_modules/chart.js/dist/chart.js:6224:41)
  at each(../../node_modules/chart.js/dist/chunks/helpers.segment.js:56:12)
  at _a.bindUserEvents(../../node_modules/chart.js/dist/chart.js:6224:10)
  at _a.bindEvents(../../node_modules/chart.js/dist/chart.js:6205:10)
  at _a._checkEventBindings(../../node_modules/chart.js/dist/chart.js:5903:12)
  at _a.update(../../node_modules/chart.js/dist/chart.js:5852:10)
  at this._doResize(../../node_modules/chart.js/dist/chart.js:5620:46)
  at sentryWrapped(../../node_modules/@sentry/browser/esm/helpers.js:37:17)

By ensuring that addEventListener and removeEventListener are called on truth-y values, Chart.js can prevent these TypeErrors from occurring and therefore make implementing applications more stable when integrating chart.js.

Closes #11677

@LeeLenaleee LeeLenaleee added this to the Version 4.5.0 milestone Feb 27, 2024
@DAcodedBEAT
Copy link
Contributor Author

Thanks for the approvals @LeeLenaleee and @etimberg!
When can this be merged and what is the ETA for it's release?

@etimberg etimberg merged commit bbdaa6a into chartjs:master Feb 28, 2024
8 checks passed
@etimberg
Copy link
Member

Merged it now; we don't have a date on a next release but I think we're getting close. @LeeLenaleee thoughts?

@LeeLenaleee
Copy link
Collaborator

There are no enhancements merged so if we rename the milsestone from 4.5.0 to 4.4.2 and create a new 4.5.0 we can do a bugfix release

@etimberg
Copy link
Member

i renamed it

@DAcodedBEAT DAcodedBEAT deleted the event-listener-arg-validation branch August 30, 2024 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot read properties of null (reading 'addEventListener')
3 participants