@@ -92,7 +92,7 @@ proc add*(self: TagRef, tags: varargs[TagRef]) =
92
92
if tag.isNil():
93
93
continue
94
94
if tag.onlyChildren:
95
- for i in tag.children [0 ..^ 1 ]:
95
+ for i in tag.childNodes [0 ..^ 1 ]:
96
96
self.appendChild(i)
97
97
else :
98
98
self.appendChild(tag)
@@ -357,8 +357,12 @@ proc toSeqIter*(self: TagRef): seq[TagRef] =
357
357
result = @ []
358
358
else :
359
359
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)
362
366
return result
363
367
364
368
@@ -470,7 +474,7 @@ func getAttribute*(self: TagRef, attrName: string, default: string = ""): string
470
474
func findByTag* (self: TagRef, tag: string ): seq [TagRef] =
471
475
# # Finds all tags by name
472
476
result = @ []
473
- for child in self.children:
477
+ for child in ( when defined(js): self.childNodes else : self. children) :
474
478
when defined(js):
475
479
if child.nodeType == NodeType.TextNode:
476
480
continue
@@ -490,7 +494,7 @@ func findByTag*(self: TagRef, tag: string): seq[TagRef] =
490
494
func get* (self: TagRef, tag: string ): TagRef =
491
495
# # Returns tag by name
492
496
when defined(js):
493
- for child in self.children :
497
+ for child in self.childNodes :
494
498
if tag.toUpper() == $ child.nodeName:
495
499
return child.TagRef
496
500
raise newException(ValueError, fmt" <{ self.nodeName} > at level [{ self.lvl} ] doesn't have tag <{ tag} > " )
0 commit comments