Skip to content

fix(desktop/js): null guards for dynamic querySelector and missing returns in event handlers (Lot 4)#3327

Open
limad wants to merge 1 commit into
jeedom:developfrom
limad:fix/desktop-js-bugs-lot4-v2
Open

fix(desktop/js): null guards for dynamic querySelector and missing returns in event handlers (Lot 4)#3327
limad wants to merge 1 commit into
jeedom:developfrom
limad:fix/desktop-js-bugs-lot4-v2

Conversation

@limad
Copy link
Copy Markdown
Contributor

@limad limad commented May 8, 2026

Re-submission of #3325 targeting develop as requested.

Changes

object.js — wrong variable name in dashboard cleanup

removeId is undefined in the success callback; correct variable is id. Dashboard menu links were never cleaned after deleting an object.

overview.js — querySelector before .closest() without null guard

updateSummary called from MutationObserver — the className may not yet be in the DOM.

types.js — querySelector without null guard (×7)

  • Generic type modal: eqLogic[data-id] and cmd[data-id] lookups can return null. Added if (!el) continue.
  • Context menu callback: all 5 accesses replaced with single lookup + early if (!cmdEl) return.

scenario.js — missing return in 3 event handlers

  • .scenario_link: fell through to .action_link, opening a command config dialog.
  • #bt_cancelElementSave / #bt_crossElementSave: fell through to expressionAttr ctrl-click handler.

backup.js — querySelector on dynamic repo name

Both selectors use an API value that may have no matching DOM element.

replace.js — querySelector on dynamic eqlogicId

resetEqlogicSelect parameter may not match any rendered row.

view.js — querySelector before scrollIntoView

data-zone_id zone may not be rendered in current view.

administration.js — querySelector before .innerHTML in search

Tab anchor lookup can return null. Existing if (tabName != null) ran after the crash.

…g returns in event handlers (Lot 4)

- object.js: fix removeId→id typo in bt_removeObject success callback —
  dashboard menu links were never cleaned after object deletion
- overview.js: guard querySelector before .closest() in updateSummary —
  MutationObserver could fire with a className not yet in the DOM
- types.js: guard eqLogic/cmd querySelector in generic type modal builder
  and context menu callback — dynamic ids may not match any DOM element
- scenario.js: add missing return in .scenario_link handler (fell through
  to .action_link), and in #bt_cancelElementSave/#bt_crossElementSave
  (fell through to expressionAttr ctrl-click handler)
- backup.js: guard .bt_restoreRepoBackup and .sel_restoreCloudBackup
  querySelector — repo name from API may have no matching DOM element
- replace.js: guard .selectEqReplace querySelector in resetEqlogicSelect
- view.js: guard .lg_viewZone querySelector before scrollIntoView
- administration.js: guard tab anchor querySelector before reading innerHTML
  in search result builder
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