Skip to content

Commit 7932f5c

Browse files
committed
fix: issue #395
1 parent c8a36b1 commit 7932f5c

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/happyx/spa/tag.nim

+4-2
Original file line numberDiff line numberDiff line change
@@ -456,18 +456,20 @@ proc xml2Tag*(xml: XmlNode): TagRef =
456456

457457
proc xmlTree2Tag*(current, parent: TagRef, tree: XmlNode) =
458458
let tag = tree.xml2Tag()
459-
if not tag.isNil():
460-
current.add(tag)
461459
if tree.kind == xnElement:
462460
for child in tree.items:
463461
tag.xmlTree2Tag(current, child)
462+
if not tag.isNil():
463+
current.add(tag)
464464

465465

466466
proc tagFromString*(source: string): TagRef {.inline.} =
467467
## Translates raw HTML string into TagRef
468468
let xmlNode = parseHtml(source)
469469
result = initTag("div", @[], true)
470+
# for child in xmlNode:
470471
result.xmlTree2Tag(nil, xmlNode)
472+
# result.xmlTree2Tag(nil, xmlNode)
471473
when defined(js):
472474
result = result.children[0].children[0].TagRef
473475
else:

tests/testjs19.nim

+15
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@ import
33
../src/happyx
44

55

6+
var html =
7+
buildHtml(tDiv):
8+
rawHtml: """
9+
<div>
10+
<input type="password" />
11+
<hr>
12+
<script>
13+
var x = "Hello, world!";
14+
</script>
15+
</div>
16+
"""
17+
18+
echo html
19+
20+
621
# Declare application with ID "app"
722
appRoutes "app":
823
"/page1":

0 commit comments

Comments
 (0)