about summary refs log tree commit diff stats
path: root/src/html/dom.nim
diff options
context:
space:
mode:
Diffstat (limited to 'src/html/dom.nim')
-rw-r--r--src/html/dom.nim27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim
index 617ec404..4afa953e 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -1187,9 +1187,12 @@ proc setLocation*(document: Document, s: string): Err[JSError]
 
 # Note: we do not implement security checks (as documents are in separate
 # windows anyway).
-func href(location: Location): string {.jsuffget.} =
+func `$`(location: Location): string {.jsuffunc.} =
   return location.url.serialize()
 
+func href(location: Location): string {.jsuffget.} =
+  return $location
+
 proc setHref(location: Location, s: string): Err[JSError]
     {.jsfset: "href".} =
   if location.document == nil:
@@ -1600,21 +1603,21 @@ func getElementsByClassName(element: Element, classNames: string): HTMLCollectio
   return element.getElementsByClassName0(classNames)
 
 func previousElementSibling*(elem: Element): Element {.jsfget.} =
-  if elem.parentNode == nil: return nil
-  var i = elem.index - 1
-  while i >= 0:
-    if elem.parentNode.childList[i].nodeType == ELEMENT_NODE:
+  let p = elem.parentNode
+  if p == nil: return nil
+  for i in countdown(elem.index - 1, 0):
+    let node = p.childList[i]
+    if p.childList[i].nodeType == ELEMENT_NODE:
       return elem
-    dec i
   return nil
 
 func nextElementSibling*(elem: Element): Element {.jsfget.} =
-  if elem.parentNode == nil: return nil
-  var i = elem.index + 1
-  while i < elem.parentNode.childList.len:
-    if elem.parentNode.childList[i].nodeType == ELEMENT_NODE:
-      return elem
-    inc i
+  let p = elem.parentNode
+  if p == nil: return nil
+  for i in elem.index + 1 .. p.childList.high:
+    let node = p.childList[i]
+    if node.nodeType == ELEMENT_NODE:
+      return Element(node)
   return nil
 
 func documentElement(document: Document): Element {.jsfget.} =
s lines' href='/danisanti/profani-tty/commit/src/contact.c?id=279737badaebedccd9ce4f5e0c8baf166a346055'>279737ba ^
eb5b04df ^



6bad38c2 ^
eb5b04df ^



6bad38c2 ^
eb5b04df ^


279737ba ^

6e46e8fe ^















279737ba ^

6e46e8fe ^



279737ba ^

6e46e8fe ^



279737ba ^

6e46e8fe ^


140deeb5 ^
279737ba ^

140deeb5 ^
fef15b93 ^


140deeb5 ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115