Skip to content

Prevent getComputedStyle crash on detached canvas - #12314

Open
Yahiro025 wants to merge 1 commit into
chartjs:masterfrom
Yahiro025:cursor/fix-detached-canvas-getcomputedstyle-12312-5182
Open

Yahiro025 wants to merge 1 commit into
chartjs:masterfrom
Yahiro025:cursor/fix-detached-canvas-getcomputedstyle-12312-5182

Conversation

@Yahiro025

@Yahiro025 Yahiro025 commented Sep 18, 2026

Copy link
Copy Markdown

Description

A pending debounced _doResize can call update() after destroy() has already set chart.canvas to null. That rebound responsive events, hit _resize, and getComputedStyle threw reading element.ownerDocument on null.

This makes DOM size/position helpers return safe defaults when the element is missing, cancels the pending delayed resize on destroy(), and no-ops update / _resize / responsive rebinding once the canvas/context is gone.

Fixes #12312. Prior art: #11809 (same failure; closed without merge — still present on 4.5.1 / master).

Types of changes

  • Bug fix
  • New feature
  • Documentation
  • Refactoring / chore

Checklist

  • I have followed the contributing guidelines
  • Unit tests added (helpers.dom, core.controller, platform.basic)
  • Chrome Karma: 1710/1710 passing; lint-js / lint-md / lint-types clean

AI assistance

Implementation assisted by an AI coding agent; human-reviewed before opening.

Guard DOM size and position helpers against a null canvas and cancel
pending delayed resizes on destroy so a late update after teardown does
not throw.

Co-authored-by: Bennett Payoyo <Yahiro025@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot read properties of null (reading 'ownerDocument') in getComputedStyle when canvas is detached during a pending debounced resize

1 participant