Repository navigation
fix(memo): compare own prop membership - #1279
Merged
domgan-oai merged 1 commit intoSep 23, 2026
Merged
Conversation
domgan-oai
marked this pull request as ready for review
September 23, 2026 09:23
3 of 4 tasks
trueadm
added a commit
that referenced
this pull request
Oct 3, 2026
…d can produce (#1661) #1279 made the plain-object memo compare check own-property membership for every key, so an inherited Object.prototype value cannot stand in for a removed prop. On a plain or null-prototype object a missing own prop reads as undefined or an Object.prototype member, which is a function or an object, so a primitive that compares equal is already own. The lookup now runs only for undefined, function and object values. memo-wall's wall B bails 999 rows of four primitive props and a callback on every one_change_B; it made five lookups per row and now makes one. Paired A/B with the #833/#1069 fixes: one_change_B 0.269 -> 0.252 ms. memo-props gains a case for an own __proto__ prop holding Object.prototype (the object branch; it fails without it), and memo-wall gains a deterministic guard counting own-prop lookups per bailed row (5 on main, 1 now). Co-authored-by: Claude Opus 5.5 <[email protected]>
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
Default
memocan retain stale output when an own prop such astoString: Object.prototype.toStringis replaced bylabel: 'updated'. The old value comparison accepts the inherited method, and equal key counts hide the changed key set.Require next props to own every compared key in the shared DOM comparator. Keep the allocation-free loops, prototype gate, and exact fallback. Add an
octanepatch changeset and behavioral coverage for template and value-position children, hydration, prototype names, and explicitundefinedmembership.Universal comparisons already check ownership; server memo does not cache prop comparisons. Both have passing rendering controls. Null-prototype cases cover input handling: element APIs normalize those inputs before DOM comparison.
__proto__is a passing control rather than a pre-fix failure.Fixes #1253.
Validation
fallbackoutput in 128 DOM regression cases before the fix, across development/production compilation and hydration.memo-props,memo-value-position,conformance/memo-bailout,hook-fixes, andlazy-output, in development and production compile projects; at most two workers, no parallel files.memo-propstests passed withNODE_ENV=productionin the worker and production compilation.pnpm typecheck:filesfor source, test, and fixture.pnpm format:files:check,pnpm changeset:check, andpnpm sync.Risk / follow-ups
The ownership check adds CPU work per compared prop without adding allocations. An isolated actual-source Node 22.22.3 diagnostic used serial B-C-C-B processes, eight warmups, and 17 samples of 50,000 comparisons. Five equal plain-object props averaged 130.37 ns before and 168.41 ns after (+29.2%), with substantial variance; one/20-key equal cases were +7.4%/+8.1% and overlapped noise. Ordinary semantic controls passed. This is comparator timing, not application throughput or bundle evidence; no performance-neutral claim is made.
Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches hot-path memo prop comparison used on every memo bailout; behavior change is narrow but could slightly increase comparator cost while fixing incorrect bailouts.
Overview
Fixes memo components skipping re-renders when props swap an own key whose value matches
Object.prototype(e.g.toString) for a different own key (e.g.label).shallowEqualPropsin the memo bailout path now requires the next props object to own every key from the previous props before comparing values, so inherited prototype values cannot mask a removed own prop. Comments are updated to match; the allocation-free for-in path andObject.keysfallback for non-plain objects are unchanged.Adds an octane patch changeset and Vitest coverage (template vs value children, hydration, universal/server memo, explicit
undefinedvs missing keys, and prototype-name edge cases).Reviewed by Cursor Bugbot for commit abf8059. Bugbot is set up for automated code reviews on this repo. Configure here.