Skip to content

Commit

Permalink
feat(dom): fix empty dom event function crash
Browse files Browse the repository at this point in the history
  • Loading branch information
ilikethese authored and zealotchen0 committed Jul 25, 2023
1 parent e368ad5 commit 388beef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 0 additions & 1 deletion driver/js/src/scope.cc
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ hippy::dom::EventListenerInfo Scope::AddListener(const EventListenerInfo& event_
auto context = weak_context.lock();
if (context) {
auto callback = event_listener_info.callback.lock();
FOOTSTONE_DCHECK(callback != nullptr);
if (callback == nullptr) return;
hippy::DomEventWrapper::Set(event);
auto event_class = scope->GetJavascriptClass(kEventName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,18 @@ void NativeRenderManager::ReceivedEvent(std::weak_ptr<RootNode> root_node, uint3
FOOTSTONE_DCHECK(root != nullptr);
if (root == nullptr) return;

auto node = manager->GetNode(root_node, dom_id);
// FOOTSTONE_DCHECK(node != nullptr);
if (node == nullptr) return;
std::vector<std::function<void()>> ops = {[weak_dom_manager = dom_manager_, weak_root_node = root_node, dom_id,
params = std::move(params), use_capture = capture, use_bubble = bubble,
event_name = std::move(event_name)] {
auto manager = weak_dom_manager.lock();
if (manager == nullptr) return;

auto root = weak_root_node.lock();
if (root == nullptr) return;

auto node = manager->GetNode(root, dom_id);
if (node == nullptr) return;

std::vector<std::function<void()>> ops = {[node = std::move(node), params = std::move(params), use_capture = capture,
use_bubble = bubble, event_name = std::move(event_name)] {
auto event = std::make_shared<DomEvent>(event_name, node, use_capture, use_bubble, params);
node->HandleEvent(event);
}};
Expand Down

0 comments on commit 388beef

Please sign in to comment.