fix(js): keep TreeWalker traversal in document order (#432)

This commit is contained in:
SGavrl committed 2026-07-19 19:40:27 +00:00
1 parent 29e20ae970
commit c12915a1a6
4 files changed
+210 -12

No files matched your search

+7
View File
@@ -268,6 +268,13 @@ fn op_dom_inner(state: &OpState, cmd: String, arg1: String, arg2: String) -> Str
"prev_sibling" => n.prev_sibling, _ => None,
}).flatten().map(|id| id.index().to_string()).unwrap_or("-1".into())
}
"next_in_subtree" => {
let root = NodeId::new(arg1.parse::<u32>().unwrap_or(0));
let current = NodeId::new(arg2.parse::<u32>().unwrap_or(0));
dom.next_in_subtree(root, current)
.map(|id| id.index().to_string())
.unwrap_or("-1".into())
}
"child_nodes" => {
let nid = arg1.parse::<u32>().unwrap_or(0);
let ids: Vec<i32> = dom.children(NodeId::new(nid)).iter().map(|id| id.index() as i32).collect();