add updating guard to binding callback #5126
Merged
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.
Fixes #3180
Fixes #5117
binding callback should be called only when changes happen internally.
similar with
<input bind:value>
, the on input only call when typing into the input, but not when programmatically set theinput.value
.a brief description of the bug:
<Component bind:value />
and when we$$invalidate(value)
from outside,component.$set({ value })
which internally calls$$invalidate(value_internal)
$$.bound[value]()
$$invalidate(value)
component.$set({ value })
which internally calls$$invalidate(value_internal)
!safe_not_equal(value, value_internal)
, so the binding callback,$$.bound[value]()
, did not get called.as you can see from the sequence of steps,
$$invalidate(value)
get called twice.Also, it seemed like it will add quite some bytes into the compiled code, should we rename the variable to a shorter name?
or use
1
/0
instead oftrue
/false
?Before submitting the PR, please make sure you do the following
npm run lint
!)Tests
npm test
oryarn test
)