diff --git a/karaxdsl.nim b/karaxdsl.nim index a96c70a..6b8e540 100644 --- a/karaxdsl.nim +++ b/karaxdsl.nim @@ -4,6 +4,7 @@ from strutils import startsWith, toLowerAscii const StmtContext = ["kout", "inc", "echo", "dec", "!"] + SpecialAttrs = ["id", "class", "value", "key"] proc getName(n: NimNode): string = case n.kind @@ -72,7 +73,7 @@ proc tcall2(n, tmpContext: NimNode): NimNode = let key = getName x[0] if key.startsWith("on"): result.add newCall(!("set" & key), tmp, x[1]) - elif key == "id" or key == "class" or key == "value": + elif key in SpecialAttrs: result.add newDotAsgn(tmp, key, x[1]) else: result.add newCall(bindSym"setAttr", tmp, newLit(key), x[1]) diff --git a/vdom.nim b/vdom.nim index 6d94d97..5a2126b 100644 --- a/vdom.nim +++ b/vdom.nim @@ -31,8 +31,10 @@ const type EventHandler* = proc (ev: Event; target: VNode) {.closure.} + VKey* = int VNode* = ref object kind*: VNodeKind + key*: VKey id*, class*, text*: cstring kids: seq[VNode] # even index: key, odd index: value; done this way for memory efficiency: