Repository navigation
fix(v-model): snapshot the assigned select value before invoking the assigner - #1
Merged
haoku123 merged 1 commit intoAug 17, 2026
Conversation
…assigner (vuejs#10505) The updated-hook guard compared the model against the same object that was handed to the change handler. A handler that mutates the received value in place (e.g. Set#delete to enforce a constraint) therefore compared the value with itself, the override went undetected and the DOM was left out of sync. Snapshot Set/array values before calling the assigner (which runs the handler synchronously), and add regression tests for in-place mutation and for clearing the model to null - the original vuejs#10505 scenario.
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.
Found one more way for the model and the DOM to fall out of sync while testing your branch for vuejs#15298:
_assignedValuestores the same object that is handed to the change handler, so a handler that mutates the received value in place compares the value against itself and the override goes undetected.Repro (fails on your branch head):
User selects
foo+bar→ model ends up{'foo'}, butbarstays selected in the DOM: inupdated,valueand_assignedValueare the same (mutated) Set, soassignedValueEqualsreturnstrueandsetSelectedis skipped.Fix: snapshot Set/array values instead of storing the live reference — and take the snapshot before calling
el[assignKey](...), because the assigner invokes the handler synchronously (snapshotting after the call captures the already-mutated value; that variant still fails the test).Also added a regression test for clearing the model to
nullin the change handler — the original scenario from vuejs#10505 (it already passes on your branch, it just had no coverage).Full
runtime-domsuite passes (245 tests).