Repository navigation
Avoid duplicate check listeners after reconnecting - #84
Merged
liuliu-dev merged 2 commits intoOct 19, 2026
Merged
liuliu-dev merged 2 commits into
liuliu-dev merged 2 commits into
Conversation
There was a problem hiding this comment.
🟢 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
approved these changes
Oct 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 threetask-lists-checkevents, 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.