Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

659 B
Raw Blame
use super::*;

pub(super) fn bridge_handle_lookup_callback(
    scope: &mut v8::PinScope<'_, '_>,
    args: v8::FunctionCallbackArguments<'_>,
    mut rv: v8::ReturnValue<'_, v8::Value>,
    lookup: impl FnOnce(&JsContextHost, DomHandle) -> Option<DomHandle>,
) {
    let Some(handle) = callback_arg_dom_handle(scope, &args, 0) else {
        rv.set_null();
        return;
    };
    let bridge = args.this();
    let Ok(runtime_ptr) = runtime_ptr_from_object(scope, bridge) else {
        rv.set_null();
        return;
    };
    let result = lookup(unsafe { &*runtime_ptr }, handle);
    set_wrapped_handle_or_null(scope, &mut rv, runtime_ptr, result);
}