Skip to content

refactor(core): small cleanups (isFunction, _queueDelete, isDomRendererActive)#17

Merged
chiefcll merged 1 commit into
mainfrom
refactor/small-cleanups
May 21, 2026
Merged

refactor(core): small cleanups (isFunction, _queueDelete, isDomRendererActive)#17
chiefcll merged 1 commit into
mainfrom
refactor/small-cleanups

Conversation

@chiefcll
Copy link
Copy Markdown
Contributor

Summary

Three small cleanups against src/core, each independent of the others.

  • isFunc removed; isFunction kept. core/utils.ts exported both — isFunc used obj instanceof Function, isFunction used typeof obj === 'function'. The typeof form is faster (no prototype-chain walk) and was already what focusManager.ts used. The other 7 call sites in elementNode.ts, dom-renderer/domRendererUtils.ts, and primitives/useMouse.ts now match.

  • _queueDelete check. The post-mutation delete-flush had Number(el._queueDelete) < 0, which was defensive against an uninitialized shape. The constructor now initializes _queueDelete = undefined explicitly, so (el._queueDelete ?? 0) < 0 is clearer and avoids the Number(undefined) === NaN trap.

  • isDomRendererActive() helper. The pair DOM_RENDERING && Config.domRendererEnabled (or its negation) was repeated 13× across shaders.ts, lightningInit.ts, and elementNode.ts. Replaced with a single helper exported from config.ts. Kept as a function (not a const) because Config.domRendererEnabled is mutable until the renderer starts.

What changes for callers

Nothing — isFunc and DOM_RENDERING aren't part of the documented public API, and the behavior of every replaced expression is identical. isDomRendererActive is a new export.

Test plan

  • npm run tsc — clean
  • npm test — 120/120 pass
  • npm run lint — 0 errors

🤖 Generated with Claude Code

…erActive)

- Remove duplicate isFunc (`instanceof Function`) in favor of isFunction
  (`typeof === 'function'`). The typeof check is faster and was already the
  one used in focusManager; the rest of the codebase now matches.
- Replace `Number(el._queueDelete) < 0` with `(el._queueDelete ?? 0) < 0` in
  the post-mutation delete-flush. The cast was defensive against an old shape
  where _queueDelete might not be initialized; now that the constructor sets
  it explicitly, ?? is clearer and avoids the Number(undefined) === NaN trap.
- Add `isDomRendererActive()` helper in config.ts and use it everywhere the
  `DOM_RENDERING && Config.domRendererEnabled` pair was repeated (shaders.ts
  ×9, lightningInit.ts ×2, elementNode.ts ×2). One source of truth for the
  gate.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@chiefcll chiefcll merged commit bfd38ff into main May 21, 2026
1 check passed
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