From 1b68e3c5f2e49e21b46516ca3841ac17ddbbfc6d Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 02:26:08 +0000 Subject: [PATCH] [decompose] extract ProfileHashtagController from js/ui/profileModalController.js Extracts all hashtag preference related logic into a new controller `js/ui/profileModal/ProfileHashtagController.js` to reduce the size of `js/ui/profileModalController.js` and improve maintainability. - Moves `normalizeHashtagTag`, `formatHashtagTag`, `getResolvedHashtagPreferences`, `setHashtagStatus`, `refreshHashtagBackgroundStatus`, `populateHashtagPreferences`, `renderHashtagList`, `sanitizeHashtagList`, `createHashtagListItem`, `persistHashtagPreferences`, `handleAddHashtagPreference`, `handleRemoveHashtagPreference`, `handleHashtagPreferencesChange`, `describeHashtagPreferencesError`. - Updates `ProfileModalController` to delegate to `ProfileHashtagController`. - Adds delegate getters/methods in `ProfileModalController` to maintain backward compatibility for tests. - Reduces `js/ui/profileModalController.js` by ~600 lines. - Updates file size baseline in `scripts/check-file-size.mjs`. Passes `npm run lint` and `npm run test:unit`. Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- .../profileModal/ProfileHashtagController.js | 8 ++++---- repro.mjs | 19 ------------------- repro_undefined.mjs | 19 ------------------- 3 files changed, 4 insertions(+), 42 deletions(-) delete mode 100644 repro.mjs delete mode 100644 repro_undefined.mjs diff --git a/js/ui/profileModal/ProfileHashtagController.js b/js/ui/profileModal/ProfileHashtagController.js index d5d5eec2..be8e8b7b 100644 --- a/js/ui/profileModal/ProfileHashtagController.js +++ b/js/ui/profileModal/ProfileHashtagController.js @@ -185,10 +185,10 @@ export class ProfileHashtagController { } clearHashtagInputs() { - if (this.hashtagInterestInput instanceof HTMLInputElement) { + if (this.hashtagInterestInput && typeof this.hashtagInterestInput.value === "string") { this.hashtagInterestInput.value = ""; } - if (this.hashtagDisinterestInput instanceof HTMLInputElement) { + if (this.hashtagDisinterestInput && typeof this.hashtagDisinterestInput.value === "string") { this.hashtagDisinterestInput.value = ""; } } @@ -385,10 +385,10 @@ export class ProfileHashtagController { : this.hashtagDisinterestInput; const rawValue = - input instanceof HTMLInputElement ? input.value || "" : ""; + input && typeof input.value === "string" ? input.value || "" : ""; const normalized = this.normalizeHashtagTag(rawValue); - if (!(input instanceof HTMLInputElement)) { + if (!(input && typeof input.value === "string")) { return { success: false, reason: "missing-input" }; } diff --git a/repro.mjs b/repro.mjs deleted file mode 100644 index 7a23d05f..00000000 --- a/repro.mjs +++ /dev/null @@ -1,19 +0,0 @@ -class Helper { - constructor() { - this.prop = null; - } -} - -class Controller { - constructor() { - this.helper = new Helper(); - } - get prop() { return this.helper.prop; } -} - -const c = new Controller(); -try { - c.prop.value = 'test'; -} catch (e) { - console.log('Error:', e.message); -} diff --git a/repro_undefined.mjs b/repro_undefined.mjs deleted file mode 100644 index bd807fd1..00000000 --- a/repro_undefined.mjs +++ /dev/null @@ -1,19 +0,0 @@ -class Helper { - constructor() { - // prop not defined - } -} - -class Controller { - constructor() { - this.helper = new Helper(); - } - get prop() { return this.helper.prop; } -} - -const c = new Controller(); -try { - c.prop.value = 'test'; -} catch (e) { - console.log('Error:', e.message); -}