use std::collections::HashMap;
use viewpoint_cdp::protocol::dom::BackendNodeId;
use crate::page::locator::AriaSnapshot;
use crate::page::ref_resolution::format_ref;
pub(crate) fn apply_refs_to_snapshot(
snapshot: &mut AriaSnapshot,
ref_map: &HashMap<usize, BackendNodeId>,
) {
if let Some(index) = snapshot.element_index {
if let Some(&backend_node_id) = ref_map.get(&index) {
snapshot.node_ref = Some(format_ref(backend_node_id));
}
snapshot.element_index = None;
}
for child in &mut snapshot.children {
apply_refs_to_snapshot(child, ref_map);
}
}