!380 事件冒泡机制从API version 5开始支持,且事件默认是冒泡的。但应兼容迁移过来的旧应用(API version4)使其默认不冒泡。

Merge pull request !380 from youzhi92/cherry-pick-1632472488
This commit is contained in:
openharmony_ci
2021-09-29 12:36:55 +00:00
committed by Gitee
@@ -130,6 +130,18 @@ bool Component::Render()
}
STOP_TRACING();
// The event bubbling mechanism is supported from API version 5, and events are bubbled by default.
// However, it should be compatible with the migrated old application (API version 4)
// so that it does not bubble by default.
const int32_t supportEventBubbleApiVersion = 5;
if (JsAppContext::GetInstance()->GetTargetApi() < supportEventBubbleApiVersion) {
UIView *view = GetComponentRootView();
if (view != nullptr) {
// make events non bubbling by default.
view->SetIntercept(true);
}
}
SetViewExtraMsg();
// step2: binding js object with this component