From 135044d8d77074fd5f901c54d432186b2c7814ac Mon Sep 17 00:00:00 2001 From: Araq Date: Tue, 5 Dec 2017 16:32:11 +0100 Subject: [PATCH] added vdom.getVNodeById for easier component creation --- karax/vdom.nim | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/karax/vdom.nim b/karax/vdom.nim index 91f4116..314b3ba 100644 --- a/karax/vdom.nim +++ b/karax/vdom.nim @@ -423,3 +423,11 @@ proc `$`*(n: VNode): kstring = else: result = "" add(result, n) + +proc getVNodeById*(n: VNode; id: cstring): VNode = + ## Get the VNode that was marked with ``id``. Returns ``nil`` + ## if no node exists. + if n.id == id: return n + for i in 0..