added track field
This commit is contained in:
parent
e63a7dbb21
commit
8195ecf61b
4 changed files with 13 additions and 7 deletions
|
|
@ -135,6 +135,8 @@ proc equalsShallow(a, b: VNode): bool =
|
||||||
if not equalsShallow(a[i], b[i]): return false
|
if not equalsShallow(a[i], b[i]): return false
|
||||||
if not sameAttrs(a, b): return false
|
if not sameAttrs(a, b): return false
|
||||||
if a.class != b.class: return false
|
if a.class != b.class: return false
|
||||||
|
if a.track != 0 and b.track != 0:
|
||||||
|
if a.track != b.track: return false
|
||||||
# XXX test event listeners here?
|
# XXX test event listeners here?
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ from strutils import startsWith, toLowerAscii
|
||||||
|
|
||||||
const
|
const
|
||||||
StmtContext = ["kout", "inc", "echo", "dec", "!"]
|
StmtContext = ["kout", "inc", "echo", "dec", "!"]
|
||||||
SpecialAttrs = ["id", "class", "value", "key"]
|
SpecialAttrs = ["id", "class", "value", "key", "track"]
|
||||||
|
|
||||||
proc getName(n: NimNode): string =
|
proc getName(n: NimNode): string =
|
||||||
case n.kind
|
case n.kind
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@ type
|
||||||
when false:
|
when false:
|
||||||
hash*: Hash
|
hash*: Hash
|
||||||
validHash*: bool
|
validHash*: bool
|
||||||
|
track*: int
|
||||||
dom*: Node ## the attached real DOM node. Can be 'nil' if the virtual node
|
dom*: Node ## the attached real DOM node. Can be 'nil' if the virtual node
|
||||||
## is not part of the virtual DOM anymore.
|
## is not part of the virtual DOM anymore.
|
||||||
|
|
||||||
|
|
@ -143,6 +144,8 @@ proc eq*(a, b: VNode): bool =
|
||||||
if a.attrs.len != b.attrs.len: return false
|
if a.attrs.len != b.attrs.len: return false
|
||||||
for i in 0..<a.attrs.len:
|
for i in 0..<a.attrs.len:
|
||||||
if a.attrs[i] != b.attrs[i]: return false
|
if a.attrs[i] != b.attrs[i]: return false
|
||||||
|
if a.track != 0 and b.track != 0:
|
||||||
|
if a.track != b.track: return false
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
proc setAttr*(n: VNode; key: cstring; val: cstring = "") =
|
proc setAttr*(n: VNode; key: cstring; val: cstring = "") =
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ proc createTableCell(id: cstring): VNode =
|
||||||
|
|
||||||
proc createTableRow(item: TableItemState): VNode =
|
proc createTableRow(item: TableItemState): VNode =
|
||||||
let className = if item.active: cstring"TableRow active" else: cstring"TableRow"
|
let className = if item.active: cstring"TableRow active" else: cstring"TableRow"
|
||||||
result = buildHtml(tr(class=className, `data-id` = &item.id)):
|
result = buildHtml(tr(class=className, `data-id` = &item.id, key = item.id)):
|
||||||
createTableCell("#" & &item.id)
|
createTableCell("#" & &item.id)
|
||||||
for i in 0..<len(item.props):
|
for i in 0..<len(item.props):
|
||||||
createTableCell(item.props[i])
|
createTableCell(item.props[i])
|
||||||
|
|
@ -53,7 +53,8 @@ proc createAnimBox(item: AnimBoxState): VNode =
|
||||||
let color = float(t10) / 10
|
let color = float(t10) / 10
|
||||||
let divStyles = cstring"border-radius: " & &t10 &
|
let divStyles = cstring"border-radius: " & &t10 &
|
||||||
"px; background: rgba(0,0,0," & cstring($color) & ")"
|
"px; background: rgba(0,0,0," & cstring($color) & ")"
|
||||||
result = flatHtml(tdiv(class="AnimBox", `data-id` = &item.id, style=divStyles))
|
result = flatHtml(tdiv(class="AnimBox", `data-id` = &item.id, key = item.id,
|
||||||
|
style=divStyles))
|
||||||
|
|
||||||
proc animCreateVNode(data: AnimState): VNode =
|
proc animCreateVNode(data: AnimState): VNode =
|
||||||
result = buildHtml(tdiv(class="Anim")):
|
result = buildHtml(tdiv(class="Anim")):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue