From 261e0a474efefe7d8e76ce25fa9c5abfcf01ff43 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 18 Sep 2024 20:16:28 -0700 Subject: [PATCH] GetDescendants --- src/runner/instance.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/runner/instance.rs b/src/runner/instance.rs index 448adc2..5ef7b6a 100644 --- a/src/runner/instance.rs +++ b/src/runner/instance.rs @@ -66,6 +66,17 @@ impl mlua::UserData for Instance{ Ok(children) }) ); + methods.add_method("GetDescendants",|lua,this,_:()| + dom(lua,|dom|{ + let children:Vec<_>=dom + .descendants_of(this.referent) + .map(|instance| + Instance::new(instance.referent()) + ) + .collect(); + Ok(children) + }) + ); methods.add_method("IsA",|lua,this,classname:mlua::String| dom(lua,|dom|{ let instance=this.get(dom)?;