Skip to content

Commit bb6f7c9

Browse files
authored
Merge pull request #259 from HapticX/dev
fix spa rendering
2 parents 3394930 + 8806c70 commit bb6f7c9

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/happyx/spa/tag.nim

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ proc add*(self: TagRef, tags: varargs[TagRef]) =
9292
if tag.isNil():
9393
continue
9494
if tag.onlyChildren:
95-
for i in tag.children[0..^1]:
95+
for i in tag.childNodes[0..^1]:
9696
self.appendChild(i)
9797
else:
9898
self.appendChild(tag)
@@ -357,8 +357,12 @@ proc toSeqIter*(self: TagRef): seq[TagRef] =
357357
result = @[]
358358
else:
359359
result = @[self]
360-
for child in self.children:
361-
result = result.concat(child.TagRef.toSeqIter)
360+
when defined(js):
361+
for child in self.childNodes:
362+
result = result.concat(child.TagRef.toSeqIter)
363+
else:
364+
for child in self.children:
365+
result = result.concat(child.TagRef.toSeqIter)
362366
return result
363367

364368

@@ -470,7 +474,7 @@ func getAttribute*(self: TagRef, attrName: string, default: string = ""): string
470474
func findByTag*(self: TagRef, tag: string): seq[TagRef] =
471475
## Finds all tags by name
472476
result = @[]
473-
for child in self.children:
477+
for child in (when defined(js): self.childNodes else: self.children):
474478
when defined(js):
475479
if child.nodeType == NodeType.TextNode:
476480
continue
@@ -490,7 +494,7 @@ func findByTag*(self: TagRef, tag: string): seq[TagRef] =
490494
func get*(self: TagRef, tag: string): TagRef =
491495
## Returns tag by name
492496
when defined(js):
493-
for child in self.children:
497+
for child in self.childNodes:
494498
if tag.toUpper() == $child.nodeName:
495499
return child.TagRef
496500
raise newException(ValueError, fmt"<{self.nodeName}> at level [{self.lvl}] doesn't have tag <{tag}>")

tests/components/component_for.nim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ component ComponentFor:
1212
@click:
1313
self.counter += 1
1414
echo i
15+
!debugCurrent
1516

1617
@created:
1718
echo "created!"

0 commit comments

Comments
 (0)