Skip to content

feat: extract FilterEngine IIFE module from JavaScript.html (Phase 1 PR4/7) - #148

Merged
cheerc merged 1 commit into
mainfrom
refactor/phase1-pr4-filter-engine
Jun 24, 2026
Merged

feat: extract FilterEngine IIFE module from JavaScript.html (Phase 1 PR4/7)#148
cheerc merged 1 commit into
mainfrom
refactor/phase1-pr4-filter-engine

Conversation

@cheerc

@cheerc cheerc commented Jun 24, 2026

Copy link
Copy Markdown
Owner

What

Extract 8 filter methods from JavaScript.html into a new FilterEngine.js.html IIFE module as part of Phase 1 IIFE domain separation (#129).

Methods Extracted (8)

Method Type Notes
loadAndApplyPersistedFilters public UI callback heavy, thisApp
toggleAllFilterCheckboxes public DOM querySelectorAll
applyFilters public Advanced filter apply
clearAdvancedFilters public Clear non-tag filters
clearAllFilters public Clear all filter state + localStorage
_filterScheduleData private Core predicate-based data filter
filterDataByTags public Tag filter pipeline
filterDataByActiveFilters public Multi-type filter pipeline

Not extracted: applyTagFilters (async, Tagify instance + modal confirm — stays in JavaScript.html as documented in NOT_EXTRACTABLE).

How

  • Created FilterEngine.js.html with standard IIFE pattern (function(App) { ... })(App)
  • Converted all this.xxxApp.xxx references (activeFilters, ui, modals, tagFilterTagify)
  • Added include in Index.html after DataCollection.js (provides App.getAllTags), before App.init()
  • Updated IIFE_EXTRACTED set in appWiringContracts.test.js (+8 methods)
  • Updated syncMethodsWiring.test.js: added filterEngineSource, updated method existence checks and wiring patterns (this\.xxxApp\.xxx)
  • Moved _filterScheduleData from PRIVATE_HELPERS to IIFE_EXTRACTED
  • Updated public method count: 26 → 19

Scope

  • FilterEngine.js.html (new)
  • JavaScript.html (removed 8 methods, added moved comments)
  • Index.html (+1 include line)
  • tests/unit/appWiringContracts.test.js (IIFE_EXTRACTED, counts)
  • tests/unit/syncMethodsWiring.test.js (source file, patterns)

Verification

  • npm test: 1147 tests passed (36 files)
  • npx eslint --ext .html .: 0 errors (8 pre-existing warnings)
  • bash scripts/check-structure.sh: all present
  • Scope gate: only expected 5 files changed

ESLint Baseline (unchanged)

8 warnings (all pre-existing: unused vars in Config, Elements, module factories)

refs #129

Extract loadAndApplyPersistedFilters, toggleAllFilterCheckboxes, applyFilters,
clearAdvancedFilters, clearAllFilters, _filterScheduleData, filterDataByTags,
and filterDataByActiveFilters from JavaScript.html into FilterEngine.js.html
as an IIFE-wrapped module. Convert all this.xxx references to App.xxx.

Update Index.html to include FilterEngine.js after DataCollection.js.
Update IIFE_EXTRACTED set in appWiringContracts.test.js.
Update syncMethodsWiring.test.js to load FilterEngine source and
adjust wiring patterns for App.xxx references.

All 1147 tests pass. ESLint 0 errors.

refs #129
Closes t-20260624065419196170-40473-8

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

Agend-Agent: cb-team-impl
Agend-Task: t-20260624065419196170-40473-8
Agend-Branch: refactor/phase1-pr4-filter-engine
Agend-Issued-At: 2026-06-24T06:56:48.671228+00:00
@cheerc

cheerc commented Jun 24, 2026

Copy link
Copy Markdown
Owner Author

✅ VERIFIED

Reviewed HEAD: 3f56068eb9fc5abf68644b989d9dcc473dfb4013
Reviewer: cb-team-reviewer
Audit mode: standard (D2 — Risk-Flag #2 touched but extraction is mechanical)

Files Reviewed (5)

  • FilterEngine.js.html (new, +141) — IIFE module with 8 extracted filter methods
  • JavaScript.html (-118) — removed 8 methods, left move comments
  • Index.html (+1) — include line for FilterEngine.js
  • tests/unit/appWiringContracts.test.js (+9/-8) — IIFE_EXTRACTED set, counts
  • tests/unit/syncMethodsWiring.test.js (+34/-14) — source, patterns, existence checks

Stage 1 — Correctness

  • All 8 methods (7 public + _filterScheduleData) correctly extracted with thisApp conversion (43 App. references, 0 residual this.)
  • IIFE pattern (function(App) { ... })(App) consistent with PR1-PR3
  • Load order: Elements → JavaScript → DataCollection → FilterEngineApp.init()
  • AppElements (global const) accessed directly — same pattern as original code
  • applyTagFilters (async, Tagify-dependent) correctly NOT extracted, remains in JavaScript.html
  • Caller sites in JavaScript.html (this.loadAndApplyPersistedFilters() at L213, L387) work correctly via this === App context
  • No cross-module callers in UtilityFunctions/LockManager/DataCollection
  • Test counts: 48 - 7(PR1) - 4(PR2) - 11(PR3) - 7(PR4) = 19 public methods ✓
  • PRIVATE_HELPERS correctly emptied, _filterScheduleData moved to IIFE_EXTRACTED
  • syncMethodsWiring: this\\.App\\. patterns for clearAdvancedFilters, clearAllFilters
  • No conflict markers in any file

Stage 2 — Adversarial

  • No hidden this context bugs — all this.xxxApp.xxx conversions verified line-by-line
  • No missing dependency: App.getAllTags (DataCollection) loads before FilterEngine
  • AppElements global scope: defined in Elements.js.html (L469), loads before FilterEngine (L479)
  • No scope leak: IIFE wraps everything, only App.xxx = assignments escape

Evidence

  • ran: gh pr checks 148 → validate: SUCCESS
  • ran: grep this\. FilterEngine.js.html → No this. references found
  • ran: conflict marker scan (5 files) → all clean
  • cited: FilterEngine.js.html:16 — (function(App) { (IIFE entry)
  • cited: FilterEngine.js.html:141 — })(App); (IIFE closure)
  • cited: Index.html:479 — FilterEngine.js after DataCollection.js
  • cited: appWiringContracts.test.js:134 — expect(publicMethods.length).toBe(19) (count verification)

@cheerc
cheerc merged commit 2a981a3 into main Jun 24, 2026
1 check passed
@cheerc
cheerc deleted the refactor/phase1-pr4-filter-engine branch June 24, 2026 07:16
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