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

platform.isAttached should return false if canvas is false-y #11707

Merged

Conversation

DAcodedBEAT
Copy link
Contributor

@DAcodedBEAT DAcodedBEAT commented Mar 7, 2024

Expected behavior

isAttached() from platform.dom.js should only call _getParentNode() on valid a truth-y canvas value.

Current behavior

TypeError: Cannot read properties of null (reading 'parentNode')
  at _getParentNode(../../node_modules/chart.js/dist/chunks/helpers.segment.js:1820:24)
  at DomPlatform.isAttached(../../node_modules/chart.js/dist/chart.js:3434:23)
  at _a.bindResponsiveEvents(../../node_modules/chart.js/dist/chart.js:6266:18)
  at _a.bindEvents(../../node_modules/chart.js/dist/chart.js:6211:12)
  at _a._checkEventBindings(../../node_modules/chart.js/dist/chart.js:5907:12)
  at _a.update(../../node_modules/chart.js/dist/chart.js:5856:10)
  at this._doResize(../../node_modules/chart.js/dist/chart.js:5624:46)
  at sentryWrapped(../../node_modules/@sentry/browser/esm/helpers.js:37:17)

From sentry:

image

Reproducible sample

.

Optional extra steps/info to reproduce

No response

Context

  • While encountering the prior contribution (Cannot read properties of null (reading 'addEventListener') #11677) seemed to be frequent, this particular issue appears to be an even more unique edge case. Nonetheless, I've implemented a fix to enhance the stability of chart.js and the applications using it.
  • Alternatively, we could check for the canvas within _getParentNode itself. I will defer that decision to the @chartjs maintainers if they want this changed.

chart.js version

4.4.2

Browser name and version

Experienced on Chrome 122.0.0 according to my project's Sentry, but probably impacts others since this is missing a null check.

Link to your project

No response

@etimberg etimberg added this to the 4.5.0 milestone Mar 8, 2024
@LeeLenaleee LeeLenaleee merged commit 1777f95 into chartjs:master Mar 11, 2024
8 checks passed
@DAcodedBEAT
Copy link
Contributor Author

Hello @etimberg / @LeeLenaleee 👋 Thanks again for the prompt review and merge. Do you have an ETA for the release of 4.5.0 ?

@DAcodedBEAT
Copy link
Contributor Author

@chartjs When should I expect this to land? Should I run a fork in production in the interim?

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.

None yet

3 participants