refactor(core): small cleanups (isFunction, _queueDelete, isDomRendererActive)#17
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three small cleanups against
src/core, each independent of the others.isFuncremoved;isFunctionkept.core/utils.tsexported both —isFuncusedobj instanceof Function,isFunctionusedtypeof obj === 'function'. Thetypeofform is faster (no prototype-chain walk) and was already whatfocusManager.tsused. The other 7 call sites inelementNode.ts,dom-renderer/domRendererUtils.ts, andprimitives/useMouse.tsnow match._queueDeletecheck. The post-mutation delete-flush hadNumber(el._queueDelete) < 0, which was defensive against an uninitialized shape. The constructor now initializes_queueDelete = undefinedexplicitly, so(el._queueDelete ?? 0) < 0is clearer and avoids theNumber(undefined) === NaNtrap.isDomRendererActive()helper. The pairDOM_RENDERING && Config.domRendererEnabled(or its negation) was repeated 13× acrossshaders.ts,lightningInit.ts, andelementNode.ts. Replaced with a single helper exported fromconfig.ts. Kept as a function (not a const) becauseConfig.domRendererEnabledis mutable until the renderer starts.What changes for callers
Nothing —
isFuncandDOM_RENDERINGaren't part of the documented public API, and the behavior of every replaced expression is identical.isDomRendererActiveis a new export.Test plan
npm run tsc— cleannpm test— 120/120 passnpm run lint— 0 errors🤖 Generated with Claude Code