fix(runtime-core): fix immediate callback not triggered bug for multisource #5467
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.
Fix this bug:
{ immediate: true }
optionundefined
the callback won't get called immediately as expected.
See reproduce buggy code detailed below( or sfc playground link):
When determining if callback should be called immediately for the first time ( relative code here ) , the
hasChanged
getfalse
for multi source(newValue
is[undefined]
andoldValue
is[]
,[undefined][0]===[][0]
) while gettrue
for single source, which cause different behaviors.This PR fix it by compare the reference value
INITIAL_WATCHER_VALUE
tonewValue
for multi source, just like what single source case do.And when we call callback, pass
undefined
for single source and[]
for multi source for the first time, keep this correct behavior.