about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-09-08 20:47:34 +0200
committerbptato <nincsnevem662@gmail.com>2023-09-08 20:47:34 +0200
commit0e4e8a6288e703af334ea52043ca8f84aa6d3465 (patch)
treeddaa43ca20a625462c37ebbe8484f4b96dea3575 /src
parent39e9d80a49124067edb38c4711c58d5cb790c91e (diff)
downloadchawan-0e4e8a6288e703af334ea52043ca8f84aa6d3465.tar.gz
dom: align some return values with their webidl
Certain functions were returning types that do not align with the
WebIDL defined in the dom standard.
Diffstat (limited to 'src')
-rw-r--r--src/html/dom.nim22
-rw-r--r--src/html/env.nim4
2 files changed, 13 insertions, 13 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim
index 1237d701..a2b6f696 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -269,7 +269,7 @@ type
     start*: Option[int]
 
   HTMLLIElement* = ref object of HTMLElement
-    value* {.jsget.}: Option[int]
+    value* {.jsget.}: Option[int32]
 
   HTMLStyleElement* = ref object of HTMLElement
     sheet*: CSSStylesheet
@@ -1031,8 +1031,8 @@ func childNodes(node: Node): NodeList {.jsfget.} =
   return node.childNodes_cached
 
 # DOMTokenList
-func length(tokenList: DOMTokenList): int {.jsfget.} =
-  return tokenList.toks.len
+func length(tokenList: DOMTokenList): uint32 {.jsfget.} =
+  return uint32(tokenList.toks.len)
 
 func item(tokenList: DOMTokenList, i: int): Option[string] {.jsfunc.} =
   if i < tokenList.toks.len:
@@ -1122,8 +1122,8 @@ func getter(tokenList: DOMTokenList, i: int): Option[string] {.jsgetprop.} =
   return tokenList.item(i)
 
 # NodeList
-func length(nodeList: NodeList): int {.jsfget.} =
-  return nodeList.len
+func length(nodeList: NodeList): uint32 {.jsfget.} =
+  return uint32(nodeList.len)
 
 func hasprop(nodeList: NodeList, i: int): bool {.jshasprop.} =
   return i < nodeList.len
@@ -1136,8 +1136,8 @@ func getter(nodeList: NodeList, i: int): Option[Node] {.jsgetprop.} =
   return option(nodeList.item(i))
 
 # HTMLCollection
-proc length(collection: HTMLCollection): int {.jsfget.} =
-  return collection.len
+proc length(collection: HTMLCollection): uint32 {.jsfget.} =
+  return uint32(collection.len)
 
 func hasprop(collection: HTMLCollection, i: int): bool {.jshasprop.} =
   return i < collection.len
@@ -1359,8 +1359,8 @@ func getNamedItemNS(map: NamedNodeMap, namespace, localName: string): Option[Att
   if i != -1:
     return some(map.attrlist[i])
 
-func length(map: NamedNodeMap): int {.jsfget.} =
-  return map.element.attrs.len
+func length(map: NamedNodeMap): uint32 {.jsfget.} =
+  return uint32(map.element.attrs.len)
 
 func item(map: NamedNodeMap, i: int): Option[Attr] {.jsfunc.} =
   if i < map.attrlist.len:
@@ -1378,8 +1378,8 @@ func getter[T: int|string](map: NamedNodeMap, i: T): Option[Attr] {.jsgetprop.}
   else:
     return map.getNamedItem(i)
 
-func length(characterData: CharacterData): int {.jsfget.} =
-  return characterData.data.utf16Len
+func length(characterData: CharacterData): uint32 {.jsfget.} =
+  return uint32(characterData.data.utf16Len)
 
 func scriptingEnabled*(document: Document): bool =
   if document.window == nil:
diff --git a/src/html/env.nim b/src/html/env.nim
index 687c577a..144a6a05 100644
--- a/src/html/env.nim
+++ b/src/html/env.nim
@@ -55,9 +55,9 @@ proc javaEnabled(navigator: ptr Navigator): bool {.jsfunc.} = false
 proc namedItem(pluginArray: ptr PluginArray): string {.jsfunc.} = ""
 proc namedItem(mimeTypeArray: ptr MimeTypeArray): string {.jsfunc.} = ""
 proc item(pluginArray: ptr PluginArray): JSValue {.jsfunc.} = JS_NULL
-proc length(pluginArray: ptr PluginArray): int {.jsfget.} = 0
+proc length(pluginArray: ptr PluginArray): uint32 {.jsfget.} = 0
 proc item(mimeTypeArray: ptr MimeTypeArray): JSValue {.jsfunc.} = JS_NULL
-proc length(mimeTypeArray: ptr MimeTypeArray): int {.jsfget.} = 0
+proc length(mimeTypeArray: ptr MimeTypeArray): uint32 {.jsfget.} = 0
 proc getter(pluginArray: ptr PluginArray, i: int): Option[JSValue] {.jsgetprop.} = discard
 proc getter(mimeTypeArray: ptr MimeTypeArray, i: int): Option[JSValue] {.jsgetprop.} = discard