Skip to content

Avoid duplicate check listeners after reconnecting - #84

Merged
liuliu-dev merged 2 commits into
github:mainfrom
feritcemkahraman:fix/avoid-duplicate-check-listeners
Oct 19, 2026
Merged

liuliu-dev merged 2 commits into
github:mainfrom
feritcemkahraman:fix/avoid-duplicate-check-listeners

Conversation

@feritcemkahraman

Copy link
Copy Markdown
Contributor

Moving a <task-lists> element out of and back into the document adds another change listener each time. After two reconnections, one checkbox change emits three task-lists-check events, which can make consumers repeat the same update.

Use the element itself as a stable event listener so reconnecting does not register another anonymous callback. The regression checks exact checked/unchecked payload counts after two reconnections.

Validation: the regression first received three events instead of one; all 6 Chromium tests now pass through the repository's Karma runner. The TypeScript/declaration build, Rollup bundle, and full ESLint check pass using the installed lockfile dependencies on Node 24. The Windows cleanup wrapper was bypassed by running the same tools directly; Firefox and WebKit were not run.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Stable listener identity prevents duplicate registrations, and the regression verifies both checkbox states after repeated reconnections.

No open issues 🎉

What changed in this PR

Prevents duplicate task-lists-check events when a <task-lists> element reconnects.

Changes:

  • Uses the element itself as a stable change listener.
  • Adds regression coverage for checked and unchecked payloads after two reconnections.
File Description
test/​test.js Verifies exact event counts after reconnecting.
src/​task-lists-element.ts Replaces the anonymous listener with handleEvent.

Review effort: Max

@liuliu-dev
liuliu-dev merged commit c896fb6 into github:main Oct 19, 2026
2 checks passed
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.

3 participants