Skip to content

refactor: deduplicate populateCategoryFilter into shared module#194

Open
JuliaKalder wants to merge 1 commit into
mainfrom
fix/issue-78
Open

refactor: deduplicate populateCategoryFilter into shared module#194
JuliaKalder wants to merge 1 commit into
mainfrom
fix/issue-78

Conversation

@JuliaKalder
Copy link
Copy Markdown
Owner

Summary

  • Extracted the repeated <select> DOM-manipulation pattern (clear old options, append new ones) into modules/ui-helpers.js as setFilterOptions(filterId, categories)
  • options/options.js: populateCategoryFilter() is now a one-liner delegating to the shared helper
  • popup/popup.js: identity-aware variant also delegates its DOM work to the shared helper; removed the stale unused getCategories import that was left over from a previous version of that function

Verification

  • node --test tests/*.test.js: 90 pass / 7 fail — the 7 failures are pre-existing on main (all in migrateV0toV1 in template-store.test.js) and are not introduced by this change
  • All 5 call-sites in options/options.js and the single call-site in popup/popup.js use the same populateCategoryFilter() signature as before — no callers needed updating

Fixes #78

🤖 Generated with Claude Code

Extract the duplicated DOM manipulation (clearing and repopulating a
<select> filter) into modules/ui-helpers.js as setFilterOptions().

- options/options.js: populateCategoryFilter() is now a one-liner that
  delegates DOM work to setFilterOptions()
- popup/popup.js: identity-aware variant likewise delegates its DOM
  work to setFilterOptions(); also removes the now-unused getCategories
  import that was left over from an earlier version of the function

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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.

[MEDIUM] populateCategoryFilter() is copy-pasted identically into popup.js and options.js

1 participant