Skip to content

Commit

Permalink
fix: watch oldValue update
Browse files Browse the repository at this point in the history
  • Loading branch information
wangshuonpu committed Sep 14, 2021
1 parent 81d30ec commit efcebac
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/view/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ Component.prototype._update = function (changes) {
);

var htmlDirective = this.aNode.directives.html;

if (this._rootNode) {
this._rootNode._update(dataChanges);
this._rootNode._getElAsRootNode && (this.el = this._rootNode._getElAsRootNode());
Expand Down Expand Up @@ -961,12 +961,15 @@ Component.prototype.watch = function (dataName, listener) {
var newValue = evalExpr(dataExpr, me.data, me);

if (newValue !== value) {
var oldValue = value;
value = newValue;

try {
listener.call(
me,
newValue,
me,
newValue,
{
oldValue: value,
oldValue: oldValue,
newValue: newValue,
change: change
}
Expand All @@ -975,7 +978,6 @@ Component.prototype.watch = function (dataName, listener) {
catch (e) {
handleError(e, me, 'watch:' + dataName);
}
value = newValue;
}
}
});
Expand Down

0 comments on commit efcebac

Please sign in to comment.