diff options
author | bptato <nincsnevem662@gmail.com> | 2022-05-10 22:51:18 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-05-10 22:51:27 +0200 |
commit | 4026a4e92957634ede3f6723e582b30064e750cd (patch) | |
tree | ba9170e6bc5f159c52920a09ce815eb5ced03e63 /src/html | |
parent | 402c01d89101d5ba77780c9bbd013d28e9711bf3 (diff) | |
download | chawan-4026a4e92957634ede3f6723e582b30064e750cd.tar.gz |
Add support for :nth-child, implement textContent
Diffstat (limited to 'src/html')
-rw-r--r-- | src/html/dom.nim | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim index 3bbe07b7..924fa7a9 100644 --- a/src/html/dom.nim +++ b/src/html/dom.nim @@ -281,6 +281,17 @@ func attrb*(element: Element, s: string): bool = return true return false +func textContent*(node: Node): string = + case node.nodeType + of DOCUMENT_NODE, DOCUMENT_TYPE_NODE: + return "" #TODO null + of CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE: + return CharacterData(node).data + else: + for child in node.childNodes: + if child.nodeType != COMMENT_NODE: + result &= child.textContent + func toInputType*(str: string): InputType = case str of "button": INPUT_BUTTON |