Skip to content

Track plugin start and stop by object identity - #12374

Open
hakarrr wants to merge 2 commits into
chartjs:masterfrom
hakarrr:fix-plugin-object-lifecycle
Open

hakarrr wants to merge 2 commits into
chartjs:masterfrom
hakarrr:fix-plugin-object-lifecycle

Conversation

@hakarrr

@hakarrr hakarrr commented Oct 26, 2026

Copy link
Copy Markdown

Problem

Replacing a local plugin object with a different object that uses the same ID skips both lifecycle hooks: the old object never receives stop, and the replacement receives update hooks without start. The same happens for anonymous inline plugins because their IDs are both undefined.

For a plugin that attaches a DOM listener in start and removes it in stop, the old listener remains attached while the replacement's listener is never installed. Destroy then calls stop on the unstarted replacement instead of the old object.

Change

Compare plugin objects, rather than their option IDs, when determining which descriptors have started or stopped. The ID still selects the plugin's options. Rebuilding descriptors for the same object does not restart it.

This follows the existing per-chart start/stop lifecycle; no new hooks or public API. It does not change the chart-initialization-only install/uninstall behavior.

Tests

10 new native tests cover same-ID and anonymous replacement, different-ID controls, disabled replacement/re-enable, registry unregister/register with the same ID, adding/removing anonymous plugins, repeated updates, and actual DOM listener transfer/cleanup. Six fail against unmodified master; four are controls.

  • Fresh frozen-lockfile install: complete ChromeHeadless suite, 1,713 tests pass.
  • Build and declaration generation pass.
  • TypeScript --noEmit and changed-file ESLint pass.

Firefox and downstream package integration tests were not run.

hakarrr and others added 2 commits October 26, 2026 23:33
Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: generaltony007 <144252170+GeneralTony007@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.

1 participant