Skip to content

Commit

Permalink
feat: 组件派发消息时通知san-devtools
Browse files Browse the repository at this point in the history
  • Loading branch information
BUPTlhuanyu committed Sep 7, 2020
1 parent 6be2d74 commit 0046128
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/view/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,19 +495,27 @@ Component.prototype._calcComputed = function (computedExpr) {
*/
Component.prototype.dispatch = function (name, value) {
var parentComponent = this.parentComponent;

// #[begin] devtool
var dispatched = false;
// #[end]
while (parentComponent) {
var receiver = parentComponent.messages[name] || parentComponent.messages['*'];
if (typeof receiver === 'function') {
receiver.call(
parentComponent,
{target: this, value: value, name: name}
);
// #[begin] devtool
dispatched = true;
// #[end]
break;
}

parentComponent = parentComponent.parentComponent;
}
// #[begin] devtool
emitDevtool('event-dispatch', dispatched ? parentComponent : null, {target: this, value: value, name: name});
// #[end]
};

/**
Expand Down

0 comments on commit 0046128

Please sign in to comment.