Fix push() dropping valid items after an invalid/fctn entry, and remo… - #177
Open
kenmckell wants to merge 1 commit into
Open
Fix push() dropping valid items after an invalid/fctn entry, and remo…#177kenmckell wants to merge 1 commit into
kenmckell wants to merge 1 commit into
Conversation
…ve dead code in cloneDeepWith
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.
This PR fixes two related bugs in
push(), both reproducible on unmodifiedmaster.1. Multi-item
push()calls could silently drop valid items.push()tracked which items should end up in the array by deleting invalid/function/listener entries out of the same array holding the original arguments, then only checked whether index 0 of that array survived before deciding whether to add anything at all:Since
deleteleaves a hole rather than shifting later items down, if the first argument in a call was invalid or a function, every other valid item in that same call was silently excluded from the array — even though its data was still merged into state and listeners still fired correctly.2. Pushing a listener object directly (
{ on: ..., handler: ... }) registered nothing.The
LISTENER_ON/LISTENER_OFFcase only removed the item from the array-bound arguments; it never called_processItem(), so registration/removal never actually happened. OnlyaddEventListener()/removeEventListener()worked.Fix:
push()now builds a clean, independent list of items that should be visible, and calls_processItem()for every recognized item type, including listeners. Also removed dead code incloneDeepWith(src/utils/mergeWith.js) that built a manual recursive clone which was always immediately discarded in favor ofstructuredClone.Testing: I wasn't able to get the full local Jest suite to run cleanly in my environment —
events.test.jsand several other suites fail withRangeError: Maximum call stack size exceededinside@ungap/structured-clone. I confirmed this is pre-existing and unrelated to this change (reproducible identically on unmodifiedmaster). Per that polyfill's own documentation, this specific error occurs when it's attached to the global scope without checking for a nativestructuredCloneimplementation first — likely a version mismatch between an older pinned Jest dependency and newer Node versions (tested on Node v22.22.1) that already providestructuredClonenatively.