diff options
author | bptato <nincsnevem662@gmail.com> | 2023-12-01 22:14:24 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-12-01 22:16:42 +0100 |
commit | 803986e2ede5619c662017a4c2e54462e0aa3512 (patch) | |
tree | 40330c13d3f8f1822e6b9ede309d8ef39570dd27 /src/html | |
parent | 0a993deab62fb0ae749b9275dcfca35871f27292 (diff) | |
download | chawan-803986e2ede5619c662017a4c2e54462e0aa3512.tar.gz |
dom: redefine Node.contains to match standard
(and expose it as a JS function)
Diffstat (limited to 'src/html')
-rw-r--r-- | src/html/dom.nim | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim index ada36a19..dd565c06 100644 --- a/src/html/dom.nim +++ b/src/html/dom.nim @@ -1721,10 +1721,12 @@ func isConnected*(node: Node): bool {.jsfget.} = func inSameTree*(a, b: Node): bool = a.rootNode == b.rootNode -# a == b or b in a's ancestors -func contains*(a, b: Node): bool = - for node in a.branch: - if node == b: return true +# a == b or a in b's ancestors +func contains*(a, b: Node): bool {.jsfunc.} = + if b != nil: + for node in b.branch: + if node == a: + return true return false func firstChild*(node: Node): Node {.jsfget.} = |